What is the default database location of an android app for an unrooted device?? Is it same as for rooted one?

只谈情不闲聊 提交于 2019-11-29 14:10:17

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.

According to Android docs at http://developer.android.com/reference/android/content/Context.html#getDatabasePath(java.lang.String) you should use context.getDatabasePath.

Works for me:

File dbFile = context.getDatabasePath(name_of_database_file);
Crime_Master_GoGo

By Default Android Stores its SQLite Database to this below link, where you can access your .db file by using shell from command prompt to get owner access using chmod for read or write permission.

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 details you can check the following link. Click here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!