how to get list of all application preferences for application,
1. I am saving shared preference in this manner
2. I know that they are in data/data/app_packagename/shared_prefs
3. THE PROBLEM: But how to get list of all preference xml files in a spinner
and read each preference, i searched in SO, but i did not found any help regarding this, how to do read all preference xml files in my application directory and access the preferences?
P.S: I am aware of SharedPreference.getAll();
, will be enough to read once i get the file?
I have wrote in bits(Rough Code), it give error when tried to run, here is the implemented method
void getList()
{
//will be invoked from onCreate to populate spinner,yes spinner is already binded
PackageManager m = getPackageManager();
String s = getPackageName();
try {
PackageInfo p = m.getPackageInfo(s, 0);
s = p.applicationInfo.dataDir;
} catch (NameNotFoundException e) {
Log.w("yourtag", "Error Package name not found ", e);
}
Log.i("dir", s=s+"/shared_prefs");
//is this write way, how to proceed from here
}
Try this
//To get the selected item
If you want to use reflection, there is an @hide function Context#getSharedPrefsFile(String name)
So you would call
Context#getSharedPrefsFile(String name).getParentFile() to get a reference to the shared_prefs dir
Then in your main class, you can refer to the preferences
The saving of preference updates is handled for you.
(Not too sure about public/private declarations!).