Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: how to get list of all preference xml's for my app and read them?
    text
    copied!<p>how to get list of all application preferences for application, </p> <p><strong>1.</strong> I am saving shared preference in this manner<img src="https://i.stack.imgur.com/p3xx6.png" alt="Activity to save key value pair in desired preference xml"></p> <p><strong>2.</strong> I know that they are in <code>data/data/app_packagename/shared_prefs</code> <img src="https://i.stack.imgur.com/pTtGS.png" alt="Preference Xml&#39;s shared_pref folder"></p> <hr> <p><strong>3. THE PROBLEM:</strong> But how to get list of all preference xml files in a spinner <img src="https://i.stack.imgur.com/tF9Aj.png" alt="enter image description here"></p> <p>and read each preference, i searched in <a href="http://stackoverflow.com">SO</a>, 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> <p><strong><em>P.S:</strong> I am aware of</em> <code>SharedPreference.getAll();</code>, will be enough to read once i get the file?</p> <p>I have wrote in bits(Rough Code), it give error when tried to run, here is the implemented method</p> <pre><code>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 } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload