0
private SQLiteDatabase db = null;
private final String DB_NAME = "myDB";

I just created a DB and tables. I need to check whether there is a db is present from another button clicking.

db = this.openOrCreateDatabase("myDB", MODE_PRIVATE, null);

1 Answer 1

1

You can check if the database file exist; you can get the database File object using getDataBasePath():

    File dbFile = getDatabasePath(DATABASE_NAME); // add the database file name like "myDatabase.db"

    if (dbFile.exists())
        Log.d("LOG_TAG", "Database exists");
    else
        Log.d("LOG_TAG", "Database doesn't exists");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.