title: Refresh the listview on deleting the item from there
body: <p>Hey guy i am working on app which contains listview in which installed apps are populated with some buttons such as uninstall.</p>
  
  <pre><code>public class MainActivity extends ListActivity {
  PackageManager packageManager;
  List&lt;ApplicationInfo&gt; applist;
  Listadapter listadapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      packageManager = getPackageManager();
  
      new LoadApplications().execute();
  
  }
  
  @Override
  protected void onListItemClick(ListView l, View v, final int position, long id) {
      super.onListItemClick(l, v, position, id);
           AlertDialog.Builder dialogBuilder = new   AlertDialog.Builder(this);
      dialogBuilder.setTitle("Choose option")
              .setItems(R.array.options, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      switch (which) {
                          case 0:
                              ApplicationInfo app = applist.get(position);
                              try {
                                  Intent intent = packageManager.getLaunchIntentForPackage(app.packageName);
  
                                  if (intent != null) {
                                      startActivity(intent);
                                  }
                              } catch (ActivityNotFoundException e) {
                                  Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
                              } catch (Exception e) {
                                  Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
                              }
                              break;
                          case 1:
                              ApplicationInfo app1 = applist.get(position);
                              Uri packageURI = Uri.parse("package:" + app1.packageName);
                              Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
                              startActivity(uninstallIntent);
                              applist.remove(listadapter.getItem(position));
                              listadapter.notifyDataSetChanged();
                              break;
                          case 2:
                              break;
                      }
                  }
              });
      dialogBuilder.setCancelable(true)
              .show();
  
  }
  
  private List&lt;ApplicationInfo&gt; checkForLaunchIntent(List&lt;ApplicationInfo&gt; list) {
      ArrayList&lt;ApplicationInfo&gt; applist = new ArrayList&lt;&gt;();
  
      for (ApplicationInfo info : list) {
          try {
              if (packageManager.getLaunchIntentForPackage(info.packageName) != null) {
                  applist.add(info);
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
      return applist;
  }
  
  private class LoadApplications extends AsyncTask&lt;Void, Void, Void&gt; {
      private ProgressDialog progress = null;
  
      @Override
      protected Void doInBackground(Void... params) {
          applist =  checkForLaunchIntent(packageManager.getInstalledApplications(PackageManager.GET_META_DATA));
  
          listadapter = new Listadapter(MainActivity.this, R.layout.list_item, applist);
  
          return null;
      }
  
      @Override
      protected void onPostExecute(Void aVoid) {
          setListAdapter(listadapter);
          progress.dismiss();
          super.onPostExecute(aVoid);
  
      }
  
      @Override
      protected void onPreExecute() {
          progress = ProgressDialog.show(MainActivity.this, null, "loading apps info,,,");
          super.onPreExecute();
      }
  
  }
  
  @Override
  protected void onPause() {
      super.onPause();
          listadapter.notifyDataSetInvalidated();
  }
  </code></pre>
  
  <p>When i click on uninstall ,the app position gets deleted first before even uninstalling the app.</p>
  
  <p>This is strings.xml</p>
  
  <pre><code>&lt;resources&gt;
      &lt;string name="app_name"&gt;AppSharer&lt;/string&gt;
      &lt;string-array name="options"&gt;
          &lt;item&gt;Open App&lt;/item&gt;
          &lt;item&gt;uninstall&lt;/item&gt;
      &lt;/string-array&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>How should i refresh the listview once i delete the item.</p>
  
  <p>Thanks !!!</p>