Reputation: 5839
I want to share variable between two android application so I stored it in shared preference but when I reinstalled the application that store the variable the second application didn't see the variable, what is the best way to share variable between two application and dealing with situation when one of them will be reinstalled
I used this code
SharedPreferences globals_prefs = ctx.getSharedPreferences("globals_prefs", Context.MODE_WORLD_WRITEABLE);
Upvotes: 1
Views: 81
Reputation: 347
When you uninstall an app shared preference and internal cache is wiped out, so the only way is to use external storage.
Upvotes: 0
Reputation: 358
The SharedPreferences
in one application is stored as a prefs.xml
file in a separate folder dedicated for you app in the Android File System. So when you uninstall an app, this folder also is deleted, thereby, all Preferences
made by your app is removed. So a better way is to use Files to store it in the sdCard.
Upvotes: 3
Reputation: 2550
Note: currently this class does not support use across multiple processes. This will be added later.
From android dev documents http://developer.android.com/reference/android/content/SharedPreferences.html
File or sqlite database on public directory would do the trick when sharing data
Upvotes: 1