Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

sqlite - Android Device Monitor "data" folder is empty

I have tested creating, inserting and retrieving data into my apps db, and know it works through usage of Log statements.

However, I wish to expedite testing and use the Android Device Monitor. However, though the db exists and data is stored, when accessing below, the data folder is empty:

enter image description here

Why would this be the case? How can this be configured to show the db file and contents?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solving the issue using an emulator

The folder /data can be empty because you are missing the proper permissions. To solve it, I had to execute the following commands.

adb shell
su

Those commands starts a shell in the emulator and grant you root rights. The command adb is located in the folder platform-tools of the Android SDK, typically installed in ~/Library/Android/sdk/ on MacOS.

chmod -R 777 /data

Modify the permissions of the folder (and subfolders recursively) /data in order to make them appear in the tool Android Device Monitor.

adb root

Finally, this command restarts adb as root. Be careful, it only works on development builds (typically emulators builds).

Afterwards, you can see the content of the folder /data and transfer the data located in. You can do it in console as well, using adb pull <remote> <locale>, such as:

adb pull /data/data/<app name>/databases/<database> .

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...