Android: Where are database files stored?

前端 未结 3 559
一个人的身影
一个人的身影 2020-12-01 05:19

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

3条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 05:32

    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.

提交回复
热议问题