SoulRayder
SoulRayder

Reputation: 5166

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?

Upvotes: 0

Views: 36

Answers (2)

CommonsWare
CommonsWare

Reputation: 1006924

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.

Upvotes: 1

DeeV
DeeV

Reputation: 36035

Yes. The package name is how the Play Store identifies apps. The device will also not install an app of the same package name without the same signature. If it has the same signature, then the new app is installed over. So a person couldn't side-load an app with the same package name.

Upvotes: 1

Related Questions