45

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?

Niko Gamulin
  • 66,025
  • 95
  • 221
  • 286

3 Answers3

34

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.

Nikhil
  • 16,194
  • 20
  • 64
  • 81
browep
  • 5,057
  • 5
  • 29
  • 37
28

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
6

In debug mode you can use adb shell and browse the directory content. In the shell you can call sqlite3 /data/data/dev.client.android/databases/clientDB.db to analyse the DB.

kuester2000
  • 6,955
  • 2
  • 21
  • 16
  • I tried typing this in the Terminal tab in Android Studio while the app was being debugged but it didn't recognize the command. The app's directory on my computer was the path in the console. Is this where I should be inputting it? – Jpaji Rajnish Jul 17 '15 at 23:24