Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit shared preferences from DDMS

I want to edit shared preferences values from DDMS, if I double click the file it doen't saves the changes. Do I do something wrong or there is special plugin for that?

like image 201
NickF Avatar asked Feb 16 '13 17:02

NickF


People also ask

Where shared preferences are stored in Android device?

Android stores Shared Preferences settings as XML file in shared_prefs folder under DATA/data/{application package} directory. The DATA folder can be obtained by calling Environment. getDataDirectory() .

Where are shared preferences?

SharedPreferences are stored in an xml file in the app data folder, i.e. SharedPreferences added during runtime are not stored in the Eclipse project. The default shared preferences file would actually be: /data/data/<package>/shared_prefs/<package>_preferences.

Why is SharedPreferences editor apply () better than SharedPreferences editor commit () for saving preferences from the main thread?

Unlike commit() , which writes its preferences out to persistent storage synchronously, apply() commits its changes to the in-memory SharedPreferences immediately but starts an asynchronous commit to disk and you won't be notified of any failures.

What are shared preferences in Android Studio?

A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them. Each SharedPreferences file is managed by the framework and can be private or shared. This page shows you how to use the SharedPreferences APIs to store and retrieve simple values.


2 Answers

First, you should probably make sure your app isn't running before doing this.

You have to use the File Explorer option. Navigate to

data -> com.yourpackage -> shared_pref

Click the xml and at the top right click pull.

Edit the xml on your computer.

Once you're done, click push (also top right).

enter image description here

If you pushed the same file to the same device to the same directory, the next time you launch the app, you should see your updated values.

like image 51
A--C Avatar answered Sep 20 '22 19:09

A--C


Just follow the steps, it is easy.

Step 1:enter image description here

Step 2: Open data/data/you package name/shared_prefs -> select your shared pref -> right click and give Save As.

enter image description here

Step 3: Save in your desired folder. I am saving in desktop folder. Dont change the name enter image description here

Step 4: Now edit the needed values in the saved file.

Step 5: Upload the edited file to shared_pref directory enter image description here

Finally close and open the app to make it work. That's all.

like image 23
Swathi Avatar answered Sep 23 '22 19:09

Swathi