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();
}
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.
TABLE_NAME; Just like files that you save on the device's internal storage, Android stores your database in your app's private folder.
In my rooted phone, it's in : /data/data/<your_app_package_name>/databases/<database_name>
exemple /data/data/com.my.package/databases/mydb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With