Search code examples
androidpreferencesglobal

Saving preference that can be read and modified by another Application


I built an application that will download and install an APK from a WebService using the technique described here:

Install Application programmatically on Android

During this installation, the Webservice sends a 'flag' that indicates if the SQLite database from the application that is being updated should be deleted or not during it´s first run.

Is there any way to set a "Global Preference" that could be read (if the flag is true, the database should be deleted) and cleared (it should be set to false after deletion to avoid deleting the database all times that app is started) during the first usage of the updated app, without saving it to the SDCard?

I know how to read the preferences from the app that is being updated but, I did´t realize how to modify these preferences from another app.

Thanks a lot.


Solution

  • SharedPreferences are unique to each App/APK - no way to share them that I'm aware of and no 'Global' equivalent.

    If you want to share data, the solution is usually some sort of ContentProvider, but that relies on both apps running at the same time.

    If you only want to hand-over a token or state, I'd suggest writing a file onto the SDCARD is probably the simplest option?