Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is my sqlite database stored in android?

I have created a sqlite database in android, I can query it inside my code but I cannot find it on the filesystem/sdcard.

I have checked the other SO questions, its NOT in data/data/package-name...

I do see a data entry on my app taking up 52kb space, so its there, furthermore when I run the app again it does not trigger a OnCreate meaning it already has the DB.

My phone is rooted & I am using a custom jelly bean rom that runs fine for all intents and purposes.

Any ideas where it could be?

CODE c#

public class SqliteHelper : SQLiteOpenHelper
{
    private const string DATABASE_NAME = "Book";
    private const int DATABASE_VERSION = 1;

public SqliteHelper(Context ctx)
    : base(ctx, DATABASE_NAME, null, DATABASE_VERSION)
{ }

// Method is called during creation of the database
public override void OnCreate(SQLiteDatabase db)
{
    db.BeginTransaction();
    try
    {
        db.ExecSQL("CREATE TABLE Chapters (Id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT NOT NULL);");

        ContentValues cv = new ContentValues();
        cv.Put("Name", "1. Family");
        db.Insert("Chapters", null, cv);
        cv.Put("Name", "2. Shopping");
        db.Insert("Chapters", null, cv);
        cv.Put("Name", "3. Work");
        db.Insert("Chapters", null, cv);

        db.SetTransactionSuccessful();
    }
    finally
    {
        db.EndTransaction();
    }

    //if(db.IsOpen())
    //  db.Close();
}
like image 775
sprocket12 Avatar asked Sep 19 '13 22:09

sprocket12


People also ask

Where is a database stored on an android app?

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.

Where is the database stored in android Studio?

TABLE_NAME; Just like files that you save on the device's internal storage, Android stores your database in your app's private folder.


1 Answers

In my rooted phone, it's in : /data/data/<your_app_package_name>/databases/<database_name>

exemple /data/data/com.my.package/databases/mydb

like image 72
S.Thiongane Avatar answered Sep 18 '22 13:09

S.Thiongane