Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Where are database files stored?

I created a SQLite database on Android device. The program can read/write to database so the database file has obviously been created. The SQLiteDatabase.mPath is set to

db.mPath = "/data/data/dev.client.android/databases/clientDB.db" 

but when I browse the directories on the device I can't locate the file clientDB.db. I looked inside data directory but it appears to be empty.

Does anyone know what could be wrong here?

like image 797
Niko Gamulin Avatar asked Jul 09 '09 17:07

Niko Gamulin


People also ask

Where are databases stored on Android?

The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.

Where are databases stored?

Database tables and indexes may be stored on disk in one of a number of forms, including ordered/unordered flat files, ISAM, heap files, hash buckets, or B+ trees. Each form has its own particular advantages and disadvantages. The most commonly used forms are B-trees and ISAM.

How do I open a DB file on Android?

To open the database inspector select View -> Tool Windows -> Database Inspector from the menu bar of Android Studio. Connect a device running on API level 26 or higher. Run the app. The database schemas appear and you can select the database you want to see.

Is there a database on Android?

database. Contains classes to explore data returned through a content provider. If you need to manage data in a private database, use the android.


2 Answers

try getDatabasePath on ContextWrapper ( http://developer.android.com/reference/android/content/ContextWrapper.html ). If you are in an Activity or Application class try:

File dbFile = getDatabasePath(MY_DB_NAME); Log.i(dbFile.getAbsolutePath()); 

Just assuming its in /data/data/my.package.name/databases/ is bad as there is no guarantee the data has not been moved to the SD card or the device/OS has just decided on a different data directory.

like image 177
browep Avatar answered Sep 21 '22 19:09

browep


If you mean you visited /data and found nothing in it, and you are examining an ordinary piece of Android hardware, that is expected. DDMS does not have permission to browse through /data.

However, at least if your app is compiled in debug mode, you can use the adb pull command at the console to download your file directly.

like image 35
CommonsWare Avatar answered Sep 18 '22 19:09

CommonsWare