3

Until Android 11 I could easily push an xml file to ./storage or ./sdcard and then copy it under /data/user_de/0/com.myapp/shared_prefs to prepare the app for testing.

However, with the new storage updates in Android 11, it seems this is not possible anymore. I even grant READ_EXTERNAL_STORAGE permissions to the app:

adb shell appops set --uid com.myapp READ_EXTERNAL_STORAGE allow
adb shell appops set --uid com.myapp WRITE_EXTERNAL_STORAGE allow
adb shell appops set --uid com.myapp MANAGE_EXTERNAL_STORAGE allow

but still I get Permission denied on a dir that is part of the shared storage:

adb shell run-as com.myapp ls -alR /sdcard/Android/media
ls: /sdcard/Android/media: Permission denied

According to this it should work but it doesn't.

Also tried the appops to allow for legacy storage with no luck:

adb shell cmd appops set com.myapp android:legacy_storage allow
adb shell am force-stop com.myapp

Any ideas on how to copy a file from pc/mac to device in a shared_prefs dir?

danizgod
  • 349
  • 1
  • 6
  • 15
  • One can not create .xml files in public Music or Pictures directory on an Android 11 device. Use public Documents or Download directory instead. – blackapps Sep 07 '21 at 09:17
  • Tried that...still doesn't work ```adb shell run-as com.myapp ls /sdcard/Download ls: /sdcard/Download: Permission denied```. Tried with Documents, /sdcard/Android/media. – danizgod Sep 07 '21 at 09:43

1 Answers1

0

you can push shared_prefs while using run-as command, just make sure you copied the file /sdcard/Android/data/com.Yourapp and then it works like a charm!

hanan
  • 532
  • 2
  • 7
  • 23