- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
76 lines
2.2 KiB
Java
76 lines
2.2 KiB
Java
package com.mbridge.msdk.newreward.function.common;
|
|
|
|
import android.database.Cursor;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import com.mbridge.msdk.MBridgeConstans;
|
|
import com.mbridge.msdk.foundation.tools.af;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class DatabaseUtils {
|
|
private DatabaseUtils() {
|
|
}
|
|
|
|
public static boolean isDatabaseAvailable(SQLiteDatabase sQLiteDatabase) {
|
|
if (sQLiteDatabase == null) {
|
|
return false;
|
|
}
|
|
try {
|
|
if (sQLiteDatabase.isOpen()) {
|
|
return !sQLiteDatabase.isReadOnly();
|
|
}
|
|
return false;
|
|
} catch (Exception unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static void beginTransaction(SQLiteDatabase sQLiteDatabase) {
|
|
if (isDatabaseAvailable(sQLiteDatabase)) {
|
|
try {
|
|
sQLiteDatabase.beginTransaction();
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("DatabaseUtils", "beginTransaction", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void setTransactionSuccessful(SQLiteDatabase sQLiteDatabase) {
|
|
if (isDatabaseAvailable(sQLiteDatabase)) {
|
|
try {
|
|
sQLiteDatabase.setTransactionSuccessful();
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("DatabaseUtils", "setTransactionSuccessful", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void endTransaction(SQLiteDatabase sQLiteDatabase) {
|
|
if (isDatabaseAvailable(sQLiteDatabase) && sQLiteDatabase.inTransaction()) {
|
|
try {
|
|
sQLiteDatabase.endTransaction();
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("DatabaseUtils", "endTransaction", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void closeCursor(Cursor cursor) {
|
|
if (cursor == null) {
|
|
return;
|
|
}
|
|
try {
|
|
cursor.close();
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("DatabaseUtils", "closeCursor", e);
|
|
}
|
|
}
|
|
}
|
|
}
|