Question

I know this question is a little stupid but I cannot find where the settings of my preferences screen are stored.

I am using shared preferences this file is located at /data/data/my.package.name/shared_prefs/common.xml. However when I change something the changes are stored. I even implemented custom controls which can store their information so far. But however I cannot figure out where the settings are stored. /data/data/my.package.name/ is only one xml file which does not contain any related information. I also checked the virtual directories for multi user devices with no luck.

Here is my xml:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res/my.package.name"
    android:persistent="true" >

    <PreferenceCategory android:title="@string/settings_basics_group" >
        <EditTextPreference
            android:key="nickname"
            android:persistent="true"
            android:positiveButtonText="@string/setting_change_name"
            android:title="@string/settings_username" />
        <my.package.name.controls.EmailPreference
            android:key="mail"
            android:title="@string/settings_email"
            custom:domains="@array/known_email_domains" />
        <Preference
            android:summary="Mars"
            android:title="@string/settings_current_location" />
        <my.package.name.controls.DatePreference
            android:key="birthday"
            android:title="@string/settings_birthday" />
    </PreferenceCategory>
</PreferenceScreen>

I would be really happy if somebody could explain me where these settings are stored.

Was it helpful?

Solution

For older Android versions including Jelly Bean (API 16) and older the answer of Dalmas is correct. So feel free to upvote that answer.

Beginning with Jelly Bean MR1 (API 17) there are new rules about path due the multiuser support:

I figured out that the settings file is located in /data/user/##/my.package.name/shared_prefs/my.package.name_preferences.xml where ## is my numeric user id.

For solving that path you need the ApplicationContext there you need to reflect mLoadedAPK and there mDataDir. For now I'm happy with that I could get the path from the debugger. Sorry to everyone who wants a ready to use code snippet, you have to do that yourself.

OTHER TIPS

The app preferences are stored in the default shared preferences that you can retrieve with PreferenceManager.getDefaultSharedPreferences().

The XML file itself is located at /data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PACKAGE_NAME_preferences.xml

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top