What is the default database location for the non-rooted Android app? Is it the same as for the roots?

I have a pretty specific question.

First let me explain what I'm trying to do, and then the problem.

Basically, I try to save the existing .db database file in the assets folder , and then after installation I want to copy the .db file from the assets to the default database on Android, Something similar to this page answer [link] How to use the existing database with the android app .

Problem . For a non-rotatable device, I cannot access /data/data/<<package name folder>>. In this case, where is the database file stored. In another sense, I want to copy the file from the assets to the default location for the databases, which DB_PATH = "/data/data/" + context.getPackageName() + "/databases/"is the case with the root device. Will it be the same for a non-root device.

+5
source share
3 answers

Yes, for both cases it will be the same way. /data/data/<application_package_name>/databases

Now, on an unloaded device, you cannot access the /data/device’s internal storage directory . That is why you cannot see the database file.

, /data/data/<application_package_name>/databases (sdcard), ddms adb pull .

adb pull /data/data/<application_package_name>/databases/<database_file_name> , .

Android /data/data/<application_package_name>/databases. .

+7

Android http://developer.android.com/reference/android/content/Context.html#getDatabasePath(java.lang.String) context.getDatabasePath.

:

File dbFile = context.getDatabasePath(name_of_database_file);
+7

By default, Android Saves its SQLite database at this link below, where you can access your .db file using the shell from the command line to access the owner using chmod to read or write.

String DATABASE_PATH = "/data/data/" + PACKAGE_NAME + "/databases/" + DATABASE_NAME;

Where:
String DATABASE_NAME = "your_dbname";
String PACKAGE_NAME = "com.example.your_app_name";

For more information, you can check the following link. Press here

0
source

All Articles