Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete shared preferences using an adb command

I need to delete a shared preferences file using an adb command. Is there a way to do that without uninstalling the app?

I could not find anything that did it?

like image 268
user3547028 Avatar asked May 27 '14 16:05

user3547028


People also ask

How do I delete shared preferences?

Clearing shared preferences To clear all the values in the shared preferences file, call the clear() method on the shared preferences editor and apply the changes. SharedPreferences.

Can shared preferences be deleted?

The data stored in SharedPreferences can be edited and deleted.

How do I delete system files using adb?

To remove the app go into your Android device's shell by running adb shell . Once there, run pm uninstall -k --user 0 package.name (replacing package.name with the name of the package you searched for earlier). You can also run adb shell pm uninstall -k --user 0 package.name if you choose.


2 Answers

If you want to clear all the preferences, a single command will do it:

adb shell pm clear <package name>

like image 128
Flávio Faria Avatar answered Sep 18 '22 14:09

Flávio Faria


Definitely not on an unrooted phone. On normal consumer builds (user builds), only the application itself can access the app's data.

If you have root, you can access the shell via

adb shell

Then navigate to the app's data directory (/data/data/<package name>), find the file and rm it.

Alternatively, you can do it all at once with

adb shell rm /data/data/<package name>/<file name> 
like image 33
Chris Thompson Avatar answered Sep 22 '22 14:09

Chris Thompson