title: Interception of Installed Applications on android device
body: <p>I got the list of Package name &amp; Label of installed application in database, Now I want to interception with installed application and database. Suppose any application delete from device then I want changes in Database. for that i am using broadcast receiver but my code not works.</p>
  
  <pre><code>PackageManager pm = this.getPackageManager();
  List &lt; ApplicationInfo &gt; list = getPackageManager().getInstalledApplications(PackageManager.PERMISSION_GRANTED);
  for (int n = 0; n &lt; list.size(); n++) {
      Apps.add(list.get(n).loadLabel(pm).toString());
      AppsP.add(list.get(n).packageName.toString());
      Log.w("Installed Applications", list.get(n).loadLabel(pm).toString());
      Log.w("Installed Applications Package", list.get(n).packageName.toString());
  
  
      ...
      In other class
  
      public class PackageReceiver extends BroadcastReceiver {
  
          @Override
          public void onReceive(Context context, Intent intent) {
              // TODO Auto-generated method stub
              if (intent.getAction().equalsIgnoreCase(Intent.ACTION_PACKAGE_ADDED)) {
                  String added_package = intent.getData().toString();
                  Log.i("PackageReceiver", "Package Added = " + added_package);
  
              } else if (intent.getAction().equalsIgnoreCase(Intent.ACTION_PACKAGE_REMOVED)) {
                  String removed_package = intent.getData().toString();
                  MyDBHelper DB = new MyDBHelper(context);
                  Log.i("PackageReceiver", "Package removed = " + removed_package);
                  DB.open();
                  DB.deleteStmt = DB.db.compileStatement(QueryManager.ApplicationDelete);
                  DB.deleteStmt.bindString(1, removed_package);
                  DB.close();
  
              }
  </code></pre>
  
  <p>any help??</p>