How to compare string with arraylist

前端 未结 1 1574
感动是毒
感动是毒 2021-01-29 04:20

How to comapre value with arraylist? Form database below is my code. I just want to filter only that values which are present in the database. I just want to filter array list a

相关标签:
1条回答
  • 2021-01-29 04:48

    I just change a few bits in your array list.

    for (int i = 0; i < packs.size(); i++) {
      PackageInfo p = packs.get(i);
      ApplicationInfo applicationInfo = p.applicationInfo;
      String arrayval= arraylist.get(i).toString();
      if (arrayval.equals(p.packageName))
      {
        App app = new App();
        app.setTitle(p.applicationInfo.loadLabel(packageManager).toString());
        app.setPackageName(p.packageName);
        app.setVersionName(p.versionName);
        app.setVersionCode(p.versionCode);
        CharSequence description = p.applicationInfo.loadDescription(packageManager);
        app.setDescription(description != null ?    description.toString(): "");
        apps.add(app);
      }
    }
    

    You were trying to compare complete arrayList with a String hence that is NOT POSSIBLE

    0 讨论(0)
提交回复
热议问题