title: save state of listview clicked item
body: <p>in my activity I have a listview contain many item and list have multichoice mode. I want to save the state of selected item of listview so when a user select items in listview and close the app and re launch app the previously selected item should already selected.thank </p>
  
  <p>here my activity class.</p>
  
  <pre><code>import android.app.Activity;
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.content.SharedPreferences.Editor;
  import android.content.pm.ApplicationInfo;
  import android.content.pm.PackageInfo;
  import android.content.pm.PackageManager;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.widget.AbsListView;
  import android.widget.ListView;
  import android.widget.Toast;
  
  public class ApkListActivity extends Activity {
  
      PackageManager packageManager;
      ListView apkList;
      Editor editor;
      List&lt;PackageInfo&gt; packageList;
      String pname = "";
      SharedPreferences sharedPrefs;
      int po;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      packageManager = getPackageManager();
      final List&lt;PackageInfo&gt; packageList = packageManager
          .getInstalledPackages(PackageManager.GET_PERMISSIONS);
  
      List&lt;PackageInfo&gt; packageList1 = new ArrayList&lt;PackageInfo&gt;();
  
      /* To filter out System apps */
      for (PackageInfo pi : packageList) {
          boolean b = isSystemPackage(pi);
          if (!b) {
          packageList1.add(pi);
          }
      }
  
      Collections.sort(packageList1, new Comparator&lt;PackageInfo&gt;() {
          public int compare(PackageInfo o1, PackageInfo o2) {
          return o1.applicationInfo
              .loadLabel(getPackageManager())
              .toString()
              .compareTo(
                  o2.applicationInfo.loadLabel(
                      getPackageManager()).toString());
          }
      });
  
      apkList = (ListView) findViewById(R.id.applist);
      apkList.setAdapter(new ApkAdapter(this, packageList1, packageManager));
      apkList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
  
      }
  
  
  
      private boolean isSystemPackage(PackageInfo pkgInfo) {
      return ((pkgInfo.applicationInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) != 0) ? true
          : false;
      }
  
  }
  </code></pre>