3

I have workprofile app installed, and the location of the data can be access programmatically using getExternalFilesDir("logs") which, results in storage location as /storage/emulated/11/Android/data/com.example.workprofile/files/logs.

I would like to know how to push data to logs folder and pull using adb.

user755
  • 2,521
  • 3
  • 18
  • 29

1 Answers1

0

Let's assume you want to copy the file called data.log. The following commands will push the file into a temporary folder

adb shell push data.log /data/local/tmp

and then you can copy it into your app's private area:

adb shell run-as com.example.workprofile cp /data/local/tmp/data.log /data/data/com.example.workprofile/files/logs/data.log

If you want to pull the file you can do the opposite but you have to make sure that the file you want to copy already exists in the /data/local/tmp folder to workaround the permission deny issue (if the file does not exist).

Hope this helps.

Lino
  • 5,084
  • 3
  • 21
  • 39
  • Above methods works for path `/data/data/com....` however, doesnt work for App on workprofile as different sdcard paths say `/storage/emulated/11/Android/data/...` and results in `permission denied` – user755 Jun 15 '20 at 09:38
  • This only works on Android 11 (and beyond) when the application has `WRITE_EXTERNAL_STORAGE` permissions. If not, the app cannot access `/data/local/tmp` nor any other (temporary) directory I know of. So the file can be pushed just fine, but it can't be seen / accessed by the work profile user. – Thomas Keller Apr 23 '21 at 10:11