45 lines
1.3 KiB
Java
45 lines
1.3 KiB
Java
package com.ubt.jimu.base.db;
|
|
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.gen.DaoMaster;
|
|
import com.ubt.jimu.gen.DaoSession;
|
|
import org.greenrobot.greendao.database.Database;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DatabaseUtils {
|
|
public static final String LOCAL_DB = "local";
|
|
|
|
private static DaoSession getDaoSession(Database database) {
|
|
return new DaoMaster(database).newSession();
|
|
}
|
|
|
|
private static Database getReadableDb(Context context, String str) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
str = "local";
|
|
}
|
|
return new DaoMaster.DevOpenHelper(context, str).getReadableDb();
|
|
}
|
|
|
|
private static Database getWritableDb(Context context, String str) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
str = "local";
|
|
}
|
|
return new DaoMaster.DevOpenHelper(context, str).getWritableDb();
|
|
}
|
|
|
|
public static DaoSession getDaoSession(boolean z) {
|
|
return JimuApplication.l().e();
|
|
}
|
|
|
|
private static Database getReadableDb() {
|
|
return getReadableDb(JimuApplication.l(), Cache.getInstance().getUserId());
|
|
}
|
|
|
|
private static Database getWritableDb() {
|
|
return getWritableDb(JimuApplication.l(), Cache.getInstance().getUserId());
|
|
}
|
|
}
|