private List<InstalledApp> _initialize_data(){
  String where_clause="_isignored = 0";
  Activity activity=getActivity();
  if (activity != null) {
    SharedPreferences pref=PreferenceManager.getDefaultSharedPreferences(activity);
    boolean show_system=pref.getBoolean(SettingsFragment.KEY_PREF_SHOW_SYSTEM,false);
    if (!show_system) {
      where_clause+=" and _systemapp = 0";
    }
  }
  List<InstalledApp> installed_apps=InstalledApp.find(InstalledApp.class,where_clause);
  if (installed_apps.size() == 0 && activity != null) {
    Log.v(MainActivity.TAG,"Populating database...");
    InstalledApp.generate_applist_from_system(activity.getPackageManager());
    installed_apps=InstalledApp.find(InstalledApp.class,"_systemapp = 0 AND _isignored = 0");
    Log.v(MainActivity.TAG,"...database populated. " + InstalledApp.count(InstalledApp.class) + " records created.");
    activity.invalidateOptionsMenu();
  }
 else   if (activity != null) {
    Log.v(MainActivity.TAG,installed_apps.size() + " records read from the database.");
  }
  return installed_apps;
}

private List < InstalledApp > _initialize_data ( ) { String where_clause = "_isignored = 0" ; Activity activity = getActivity ( ) ; if ( activity != null ) { SharedPreferences pref = PreferenceManager . getDefaultSharedPreferences ( activity ) ; boolean show_system = pref . getBoolean ( SettingsFragment . KEY_PREF_SHOW_SYSTEM , false ) ; if ( ! show_system ) { where_clause += " and _systemapp = 0" ; } } List < InstalledApp > installed_apps = InstalledApp . find ( InstalledApp . class , where_clause ) ; if ( installed_apps . size ( ) == 0 && activity != null ) { Log . v ( MainActivity . TAG , "Populating database..." ) ; InstalledApp . generate_applist_from_system ( activity . getPackageManager ( ) ) ; installed_apps = InstalledApp . find ( InstalledApp . class , "_systemapp = 0 AND _isignored = 0" ) ; Log . v ( MainActivity . TAG , "...database populated. " + InstalledApp . count ( InstalledApp . class ) + " records created." ) ; activity . invalidateOptionsMenu ( ) ; } else if ( activity != null ) { Log . v ( MainActivity . TAG , installed_apps . size ( ) + " records read from the database." ) ; } return installed_apps ; }
this method loads the list of installed applications from the database , or generates it if no data exists .
