Question

I have multiple apps that have some sort of in-app currency (i.e gold).

The gold (Integer value) should be accessable through all of my apps. All of my own apps should be able to read/write the value.

It is important that only my apps are able to write the value, it doesn't matter if anyone else can read it. It's also important that I do not know which of my apps is installed. There is no 'main'-app at all. It should be irrelevant which of my apps is installed and in which order.

The value does not have to be shared between the apps during runtime, I rather thought of something like sharedPreferences or an SQL database.

Where/How should I store this value? Which is the preferred solution to this problem (if there is any)?

Était-ce utile?

La solution

If you need to share data between two (or more) apps, you can set to them the same android:sharedUserId (in AndroidManifest.xml) so the other app can read/write in the private data of the other app.

android:sharedUserId

The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process.

Doc here.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top