Get database path

You can use getDatabasePath method inside your helper's constructor:

public class MyDatabase extends SQLiteAssetHelper {

    private static final String DATABASE_NAME = "wl.db";
    private static final int DATABASE_VERSION = 1;  
    public String databasePath = "";    

    public MyDatabase(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);

        databasePath = context.getDatabasePath("wl.db").getPath();
    }

To get the path of Sqlite data base

here I am writing two ways to get the path.

(1) using custom method

public String getDbPath(Context context,String YourDbName)
{
    return context.getDatabasePath(YourDbName).getAbsolutePath();
}

(2) using File class

  File path=context.getDatabasePath("YourDbName");
  String db_path=path.getAbsolutePath();
  Log.i("Path:",db_path);

even you will see the both code ...then both code is same, 1st one is the shortcut method to get the database path, and it's occupy the less memory compare to second option.


You can get path by context.getDatabasePath(DataBaseHelper.dbName)