private boolean checkDataBase() {
SQLiteDatabase checkDB = null;
try {
File database=myContext.getDatabasePath(DB_NAME);
if (database.exists()) {
Log.i("Database", "Found");
String myPath = database.getAbsolutePath();
Log.i("Database Path", myPath);
checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
} else {
// Database does not exist so copy it from assets here
Log.i("Database", "Not Found");
}
} catch(SQLiteException e) {
Log.i("Database", "Not Found");
} finally {
if(checkDB != null) {
checkDB.close();
}
}
return checkDB != null ? true : false;
}
Free Android Tutorials, Android Tips, Android Developments, Free Android Codings., Free Android App Examples, Open Source Code for Android
Friday, 25 April 2014
In Android, check if sqlite database exists fails from time to time
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment