I have a settings application from which i have to retrieve other applications preferences, but i don't have the details of keys in them, how can i retrieve all the available keys and values in that preference?
Thanks, Swathi
I have a settings application from which i have to retrieve other applications preferences, but i don't have the details of keys in them, how can i retrieve all the available keys and values in that preference?
Thanks, Swathi
It's simple to retrieve store shared preferences data of one application to another application.
Step 1: add the same
android:sharedUserId="android.uid.shared"
in both app's manifest files.Step 2: Store Value application1
Step 3: Get Value From application2
It can work if we want read perference value from other app/pkg/process. but there is something wrong in jkhouw1's answer:
It should be :
though , CONTEXT_IGNORE_SECURITY and MODE_WORLD_WRITEABLE with the same value of "int 2" At all ,thanks for this question and answers.
Unfortunately the docs now don't even explain MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE, instead saying:
This constant was depreciated in API level 17. Creating world-readable files is very dangerous, and likely to cause security holes in applications. It is strongly discouraged; instead, ....etc
Since the depreciation, implementing file sharing between apps with sharedpreferences may be too risky, although it was simple. I'm not too concerned with security holes from the MODE_WORLD_READABLE mode in game apps where I just want to be able to transfer characters from one app to another. It's too bad they depreciated both sharing modes.
Additionally you have to add same android:sharedUserId in the both app's manifest file.
Assuming the preference are WORLD_READABLE, this might work:
Okay! using this code in Application 1 ( with package name is "com.sharedpref1" ) to store data with Shared Preferences.
And using this code in Application 2 to get data from Shared Preferences in Application 1. We can get it because we use MODE_WORLD_READABLE in application 1:
More information please visit this URL: http://androiddhamu.blogspot.in/2012/03/share-data-across-application-in.html