SoulRayder SoulRayder - 2 months ago 12
Java Question

Storing list of android apps

Is the android app package name unique across all apps on the device as well as the Market?

I want to store all app related information in a data structure. Right now, I am planning to use HashMap for this purpose.

HashMap<string,AppInfo> appList; //string (key), value is AppInfo object


Here I am planning to use the app package name (E.g. com.a.b.c) as the key since I believe it is unique to the android app. Appinfo (value) is a custom object that contains the app-related information I need.

Is this the best choice for data structure (in terms of ease of access and easy addition and deletion) and key property? Any suggestions that are better design-wise and/or performance-wise?

Answer

Is the android app package name unique across all apps on the device as well as the Market?

It is unique across all apps on the device. For any given app, it is unique on the Play Store. However:

  • that may not be true of other distribution channels, though ideally it would be

  • a given app may have multiple distinct versions on the distribution channel (alpha vs. release, APK splits for NDK binaries), each of which would have the same package name (a.k.a., application ID)

Is this the best choice for data structure (in terms of ease of access and easy addition and deletion) and key property?

That's impossible to answer in the abstract.

Any suggestions that are better design-wise and/or performance-wise?

If your number of apps is small, you might consider an ArrayMap or SimpleArrayMap for better memory consumption.

If your number of apps is huge, plan to store them in a database, and look them up from there.