|
|
@ -107,6 +107,9 @@ abstract public class AbstractDatabase {
|
|
|
|
public synchronized final void openForWriting() {
|
|
|
|
public synchronized final void openForWriting() {
|
|
|
|
initializeHelper();
|
|
|
|
initializeHelper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(database != null && !database.isReadOnly() && database.isOpen())
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
database = helper.getWritableDatabase();
|
|
|
|
database = helper.getWritableDatabase();
|
|
|
|
} catch (SQLiteException writeException) {
|
|
|
|
} catch (SQLiteException writeException) {
|
|
|
@ -127,6 +130,8 @@ abstract public class AbstractDatabase {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public synchronized final void openForReading() {
|
|
|
|
public synchronized final void openForReading() {
|
|
|
|
initializeHelper();
|
|
|
|
initializeHelper();
|
|
|
|
|
|
|
|
if(database != null && database.isOpen())
|
|
|
|
|
|
|
|
return;
|
|
|
|
database = helper.getReadableDatabase();
|
|
|
|
database = helper.getReadableDatabase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -153,9 +158,6 @@ abstract public class AbstractDatabase {
|
|
|
|
* @return sql database. opens database if not yet open
|
|
|
|
* @return sql database. opens database if not yet open
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private synchronized final SQLiteDatabase getDatabase() {
|
|
|
|
private synchronized final SQLiteDatabase getDatabase() {
|
|
|
|
// open database if requested
|
|
|
|
|
|
|
|
if(database == null)
|
|
|
|
|
|
|
|
openForWriting();
|
|
|
|
|
|
|
|
return database;
|
|
|
|
return database;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -207,6 +209,7 @@ abstract public class AbstractDatabase {
|
|
|
|
public DatabaseHelper(Context context, String name,
|
|
|
|
public DatabaseHelper(Context context, String name,
|
|
|
|
CursorFactory factory, int version) {
|
|
|
|
CursorFactory factory, int version) {
|
|
|
|
super(context, name, factory, version);
|
|
|
|
super(context, name, factory, version);
|
|
|
|
|
|
|
|
Log.e("AYAAA", "NEW DATABASE HLEPER", new Throwable());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|