Android work profile app: how to push and pull data

2.7k Views Asked by At

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.

1

There are 1 best solutions below

2
On

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.