Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have quite a specific question.

First let me explain what I am trying to do and then the problem.

Basically what I am trying to do is to store an existing .db database file in assets folder and then after installation I want to copy the .db file from assets to the default database location in Android. Something similar to this page answer [link]How to use an existing database with an Android application.

Problem For unrooted device I cannot access /data/data/<<package name folder>> . In this case where is the database file gets stored. In other term I want to copy a file from assets to applications default location for database which is DB_PATH = "/data/data/" + context.getPackageName() + "/databases/" in case of a rooted device. Would it be the same for the unrooted device.

See Question&Answers more detail:os

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

1 Answer

Yeah, For both the cases it will be same path. /data/data/<application_package_name>/databases

Now, on un-rooted device you can not access /data/ directory of device's internal storage. That's why you can not seen the database file.

If you want to get the file you can copy database file from internal storage /data/data/<application_package_name>/databases to external storage (sdcard) then using ddms or adb pull get the database file.

Also just try command adb pull /data/data/<application_package_name>/databases/<database_file_name> from your system to get the database file.

But by default all the android application store database on internal storage path /data/data/<application_package_name>/databases. And its applicable for all devices rooted or un-rooted.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...