|
|
@ -42,28 +42,6 @@ public abstract class DatabaseUtils
|
|
|
|
@Nullable
|
|
|
|
@Nullable
|
|
|
|
private static HabitsDatabaseOpener opener = null;
|
|
|
|
private static HabitsDatabaseOpener opener = null;
|
|
|
|
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
|
|
|
|
public static void executeAsTransaction(Callback callback)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try (SQLiteDatabase db = openDatabase())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
callback.execute();
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@NonNull
|
|
|
|
public static File getDatabaseFile(Context context)
|
|
|
|
public static File getDatabaseFile(Context context)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -114,14 +92,4 @@ public abstract class DatabaseUtils
|
|
|
|
if (opener == null) throw new IllegalStateException();
|
|
|
|
if (opener == null) throw new IllegalStateException();
|
|
|
|
return opener.getWritableDatabase();
|
|
|
|
return opener.getWritableDatabase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void dispose()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
opener = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface Callback
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
void execute() throws Exception;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|