tir38 / ADBX

ADB extensions
2 stars 0 forks source link

Add / remove/clear from shared prefs #98

Open tir38 opened 1 year ago

tir38 commented 1 year ago

Add a value to default shared preferences.

adb shell 'am broadcast -a org.example.app.sp.PUT --es key key_name --es value "hello world!"'

Remove a value to default shared preferences.

adb shell 'am broadcast -a org.example.app.sp.REMOVE --es key key_name'

Clear all default shared preferences.

adb shell 'am broadcast -a org.example.app.sp.CLEAR --es key key_name'

tir38 commented 1 year ago

I need to confirm these even work. I've not seen much documentation on them

tir38 commented 5 months ago

A good first step might be to list all shared pref files, and then optionally list their content.

adb shell
run-as $PACKAGE
ls -al /data/data/$PACKAGE/shared_prefs
tir38 commented 3 months ago

none of these am broadcast commands work. I can manipulate/list files contents just fine within adb shell

tir38 commented 3 months ago

I'm getting a bug today:

ax shared_prefs list com.example.beta.debug
Listing all shared prefs files for com.example.beta.debug:

run-as: couldn't stat /data/user/0/com.example.beta.debug: No such file or directory
ls: /data/data/com.example.beta.debug/shared_prefs: No such file or directory

Likely because device/ emulator wasn't fully booted. I should add a "is fully booted" check first