checking database in android
I h开发者_开发百科ave to check whether a database exists or not in android?? how can i check? It should return a boolean value after checking?plz provide me with the code.
Something like:
private boolean databaseExists() {
SQLiteDatabase checkDB = null;
try {
String myPath = DB_PATH + DATABASE_NAME;
checkDB = SQLiteDatabase.openDatabase(myPath, null,
SQLiteDatabase.OPEN_READONLY);
if(checkDB != null){
checkDB.close();
return true;
} else {
//database does not exist
return false;
}
} catch (SQLiteException e) {
//database does not exist
return false;
}
}
精彩评论