0

I`m new to Android developement. I want to know by adding this code where the database physically exists in my application folder.

SQLiteDatabase myDB = info.this.openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null);
 myDB.execSQL("CREATE TABLE IF NOT EXISTS "
     + TableName
     + " (Field1 VARCHAR, Field2 INT(3));");
 Toast.makeText(this,"Database Created", Toast.LENGTH_SHORT).show();
   /* Insert data to a Table*/
   myDB.execSQL("INSERT INTO "
     + TableName
     + " (Field1, Field2)"
     + " VALUES ('Raj Gaurav', 24);");
Zoot
  • 2,217
  • 4
  • 29
  • 47
gauravD
  • 89
  • 11

4 Answers4

4
String path = myDB.getPath()

SQLiteDatabase.getPath()

Selvin
  • 6,598
  • 3
  • 37
  • 43
1

The Default location of the SQLLiteDatabase is

   /data/data/ur packeage/databases
Balaji.K
  • 8,745
  • 5
  • 30
  • 39
1

If you want to access you data base you can use path as:

private String DB_PATH = "/data/data/"
                        + mycontext.getApplicationContext().getPackageName()
                        + "/databases/";

refer this link for more info

adding your own SQLite database to an android application

Community
  • 1
  • 1
Jaydeep Khamar
  • 5,975
  • 3
  • 32
  • 30
  • 1
    `File file = mycontext.getDatabasePath("DatabaseName");` it's possible that file does not exist. it is posible that parent directories of file doesn't exist, too. – Selvin Jun 02 '11 at 13:34
0

You can find your database in the folowing path open file explorer go to

data/data/yourprojectpath/databases

Thanks Deepak

Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243