2

I have an android app (uses sqlite db) that I created and installed on my device. It's an app for my personal use. It's debuggable and its /data/data folder is accessible from the PC with adb pull. Even overwriting the sqlite database file is possible from device explorer from within Android Studio on the PC. The device is not rooted.

I was wondering if there is a way to modify the sqlite db file within /data/data from outside Android Studio. Since AS allows modification from PC, I guess, there shouldn't be any security concerns for allowing access from outside AS from the same PC.

I have a desktop app that needs to modify the database and every time uploading the file through Android Studio device explorer is cumbersome. It would be great if I could either create a symlink or write a script to automate the process.

0

1 Answer 1

4

There is no simple command for uploading a modified database file into the app-private data directory of a debuggable app. What Android Studio does when uploading a file using Device File Explorer is this:

  1. Upload the file via adb push to /data/local/tmp/<random file name>
  2. Execute adb shell run-as com.myapp sh -c 'cp /data/local/tmp/<random file name> /data/data/com.myapp/<path>/<final file-name>'
  3. Delete the temp file via adb shell rm /data/local/tmp/<random file name>
  4. Get the updated view for Device File Explorer using adb shell run-as com.myapp sh -c 'ls -al /data/data/com.myapp/<path>/'

I discovered this by capturing the adb traffic on TCP port 5027 using Wireshark.

Note: If you overwrite the database file while the app is still running the app will most likely continue to use the old database (if the database is kept open while the app is running) until the app process is killed. I would recommend to kill the app before uploading the modified database file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .