Sharing and saving data between multiple Android applications

I am developing a group of sophisticated Android applications that must share common state and configuration settings.

For example, see the picture explaining my scenario:

enter image description here

I want APP 1, APP 2, and APP 3 to be able to access (read / write) the shared storage area. In addition, I need to remove the protection . I do not want the data to be deleted when the user uninstalls any of the applications.

I already read about SQLite, ContentProviders databases and records in internal and external repositories, but each of the above methods has the disadvantages listed below:

  • SQLite Database: The database is deleted when the application is deleted and is private for each application.
  • ContentProvider: Data is deleted when the application is deleted from ContentProvider.
  • Internal storage: personal for each application and data is deleted when the application is deleted ( http://developer.android.com/training/basics/data-storage/files.html#InternalVsExternalStorage )
  • External storage: unreliable (user can remove the SD card)
  • Store on server: impossible, the user may not have a reliable Internet connection.

EDIT:

I don’t need dependencies on Google Play services, because I will distribute applications through the Play Store and upload third-party files.

Please help me.

+7
android android-contentprovider sqlite android-externalstorage
source share
4 answers

Google Drive does this for you. Basically you get permission for the local file system supported by the remote. On most phones, this becomes preinstalled, so the uninstall issue you are worried about is an issue.

You can create a folder for your applications that you can read / write.

https://developers.google.com/drive/android/

+1
source share

You can use the shared preferences object to read and write settings data from a file. The most important thing is to use MODE_MULTI_PROCESS. The MODE_MULTI_PROCESS bit is used if several processes mutate the same SharedPreferences file.

Use the following code:

SharedPreferences shPrefernces = context.getSharedPreferences("filename", MODE_MULTI_PROCESS); String s1 = shPrefernces.getString("keytosearch1", ""); String pass = shPrefernces.getString("keytosearch2", ""); 
+1
source share

I agree that Shared Preferences with world_readable is not enough for you or for sharing over the Internet is not possible, but still you can do one thing.

Use of broadcast receivers and user broadcasts. with redundant shared data in all applications with shared preferences.

Whoever updates the data will send a broadcast to the system. All applications implement a broadcast receiver. when ever a new show has been received, they update the data in general preferences. Appendix A β†’ sends broadcast messages when updating data.

If application B is already installed, application B also receives broadcast and saves data for that purpose.

if application B updates the new data. APP B -> broadcasts for shared data. Other applications will update the data.

  • When you uninstall all applications, only general data will be lost. If at least one application is installed, the data is saved.
0
source share

Preference data will always be stored within each application context. Use sharedUserId and create a new settings file for all applications. When you open each application, the application should check the preference value from the context of all other applications and should record its preference based on the last updated time value available to find the last updated one.

Whenever an application is opened, the latest data will be saved in local. if any application is installed or uninstalled, this should work fine.

0
source share

All Articles