How to access data/data folder in Android device?

后端 未结 18 1897
南方客
南方客 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:05

    may be to access this folder you need administrative rights.

    so you have two options:-

    1. root your device and than try to access this folder
    2. use emulator

    p.s. : if you are using any of above two options you can access this folder by following these steps

    open DDMS perspective -> your device ->(Select File Explorer from right window options) select package -> data -> data -> package name ->files

    and from there you can pull up your file

    0 讨论(0)
  • 2020-11-22 16:05

    SQLlite database is store on user's Phone and it's hidding under path:

    /Data/Data/com.companyname.AppName/File/
    

    you have 2 options here:

    1. you can root your phone so that you get access to view your hidding db3 file
    2. this is not a solution but a work around. Why not just create test page that display your database table in it using 'select' statment.
    0 讨论(0)
  • 2020-11-22 16:10

    If you are using Android Studio 3.0 or later version then follow these steps.

    1. Click View > Tool Windows > Device File Explorer.
    2. Expand /data/data/[package-name] nodes.

    You can only expand packages which runs in debug mode on non-rooted device.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-22 16:12

    You can download a sigle file like that:

    adb exec-out run-as debuggable.app.package.name cat files/file.mp4 > file.mp4

    Before you download you might wan't to have a look at the file structure in your App-Directory. For this do the following steps THelper noticed above:

    adb shell
    run-as com.your.packagename 
    cd files
    ls -als .
    

    The Android-Studio way Shahidul mentioned (https://stackoverflow.com/a/44089388/1256697) also work. For those who don't see the DeviceFile Explorer Option in the Menu: Be sure, to open the /android-Directory in Android Studio. E.g. react-native users have this inside of their Project-Folder right on the same Level as the /ios-Directory.

    0 讨论(0)
  • 2020-11-22 16:13

    The easiest way (just one simple step) to pull a file from your debuggable application folder (let's say /data/data/package.name/databases/file) on an unrooted Android 5.0+ device is by using this command:

    adb exec-out run-as package.name cat databases/file > file
    
    0 讨论(0)
提交回复
热议问题