How to access data/data folder in Android device?

后端 未结 18 2113
南方客
南方客 2020-11-22 15:36

I am developing an app and I know my database *.db will appear in data/data/com.****.***

I can access this file from AVD in Eclipse with he

18条回答
  •  无人及你
    2020-11-22 16:12

    Accessing the files directly on your phone is difficult, but you may be able to copy them to your computer where you can do anything you want with it. Without rooting you have 2 options:

    1. If the application is debuggable you can use the run-as command in adb shell

      adb shell
      run-as com.your.packagename 
      cp /data/data/com.your.packagename/
      
    2. Alternatively you can use Android's backup function.

      adb backup -noapk com.your.packagename
      

      You will now be prompted to 'unlock your device and confirm the backup operation'. It's best NOT to provide a password, otherwise it becomes more difficult to read the data. Just click on 'backup my data'. The resulting 'backup.ab' file on your computer contains all application data in android backup format. Basically it's a compressed tar file. This page explains how you can use OpenSSL's zlib command to uncompress it. You can use the adb restore backup.db command to restore the backup.

提交回复
热议问题