本文整理汇总了Java中com.litesuits.orm.LiteOrm类的典型用法代码示例。如果您正苦于以下问题:Java LiteOrm类的具体用法?Java LiteOrm怎么用?Java LiteOrm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LiteOrm类属于com.litesuits.orm包,在下文中一共展示了LiteOrm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// init lite-orm
if (liteOrm == null) {
liteOrm = LiteOrm.newSingleInstance(this, "liteorm-notes");
}
// init GreenDAO
if (noteDao == null) {
DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "greendao-notes", null);
SQLiteDatabase db = helper.getWritableDatabase();
DaoMaster daoMaster = new DaoMaster(db);
DaoSession daoSession = daoMaster.newSession();
noteDao = daoSession.getNoteDao();
}
}
示例2: onCreate
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setSubTitile(getString(R.string.sub_title));
// Model Relation:school-(1,N)->classes-(1,1)->teacher-(N,N)->student-(1,N)->book
// 数据持有关系:学校 -(1,N)-> 班级 -(1,1)-> 老师 -(N,N)-> 学生 -(1,N)-> 书籍
// 模拟数据 (1,N)一对多;(N,N)多对多;(N,1)多对一;(1,1)一对一
mockData();
if (liteOrm == null) {
// 使用级联操作
DataBaseConfig config = new DataBaseConfig(this, DB_NAME);
config.debugged = true; // open the log
config.dbVersion = 1; // set database version
config.onUpdateListener = null; // set database update listener
liteOrm = LiteOrm.newCascadeInstance(config);// cascade
}
//DataBase db = LiteOrm.newCascadeInstance(this, "cascade.db");
//db.save(user);
// 与非级联交叉使用:
//db.cascade().save(user);//级联操作:保存[当前对象],以及该对象所有的[关联对象]以及它们的[映射关系],超贱!
//db.single().save(user);//非级联操作:仅保存[当前对象],高效率。
}
示例3: getInstance
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public static LiteOrm getInstance() {
if (sInstance == null) {
synchronized (LiteOrmHelper.class) {
if (sInstance == null) {
sInstance = LiteOrm.newCascadeInstance(Injection.provideContext(), DB_NAME);
sInstance.setDebugged(BuildConfig.DEBUG);
}
}
}
return sInstance;
}
示例4: createDb
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public static void createDb(Context _activity, String DB_NAME) {
DB_NAME = DB_NAME + ".db";
if (liteOrm == null) {
liteOrm = LiteOrm.newCascadeInstance(_activity, DB_NAME);
liteOrm.setDebugged(true);
}
}
示例5: getInstance
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public static LiteOrm getInstance(Context context){
synchronized (object) {
if (liteOrm == null) {
liteOrm = LiteOrm.newSingleInstance(context, "liteorm.db");
}
liteOrm.setDebugged(true); // open the log
}
return liteOrm;
}
示例6: onCreate
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
@Override public void onCreate() {
super.onCreate();
sContext = this;
Toasts.register(this);
sDb = LiteOrm.newSingleInstance(this, DB_NAME);
if (BuildConfig.DEBUG) {
sDb.setDebugged(true);
}
}
示例7: manager
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public static RxCacheManager manager() {
if (liteOrm == null) {
liteOrm = LiteOrm.newSingleInstance(context, "kakacache_journal.db");
}
liteOrm.setDebugged(true); // open the log
if (cacheManager == null) {
File storageDir = cacheDir;
if (storageDir == null || !storageDir.exists()) {
storageDir = Utils.getUsableCacheDir(context, DEFAULT_STORAGE_DIR);
}
L.log("storageDir="+storageDir);
CacheCore.Builder coreBuilder = new CacheCore.Builder();
coreBuilder.memory(new SimpleMemoryStorage());
coreBuilder.memoryJournal(new LRUMemoryJournal());
coreBuilder.memoryMax(10 * 1024 * 1024, 1000);
coreBuilder.disk(EmptyDiskStorage.INSTANCE);
if (storageDir != null) {
storageDir.mkdirs();
try {
FileDiskStorage fileDiskStorage = new FileDiskStorage(storageDir);
coreBuilder.disk(fileDiskStorage);
} catch (Exception ignored) { }
}
coreBuilder.diskJournal(new LRUDiskJournal(liteOrm));
coreBuilder.diskMax(30 * 1024 * 1024, 10 * 1000);
coreBuilder.diskConverter(new KryoDiskConverter(new Kryo()));
CacheCore core = coreBuilder.create();
cacheManager = new RxCacheManager(core, DEFAULT_EXPIRES);
}
return cacheManager;
}
示例8: getLiteOrm
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public static LiteOrm getLiteOrm() {
if (sLiteOrm == null) {
synchronized (NotificationBoxApp.class) {
if (sLiteOrm == null) {
sLiteOrm = LiteOrm.newSingleInstance(sAppContext, "box.db");
sLiteOrm.setDebugged(true);
}
}
}
return sLiteOrm;
}
示例9: onCreate
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
//初始化数据库
mLiteOrm = LiteOrm.newSingleInstance(this, "smile.db");
if (BuildConfig.DEBUG) {
mLiteOrm.setDebugged(true);
}
}
示例10: onCreate
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
sDb = LiteOrm.newSingleInstance(this, DB_NAME);
sContext = this;
Once.initialise(this);
Logger.init("AppPlusLog").setLogLevel(BuildConfig.IS_DEBUG?LogLevel.FULL:LogLevel.NONE);
sDb.setDebugged(BuildConfig.IS_DEBUG);
}
示例11: LiteOrmManager
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
private LiteOrmManager(Context context) {
if (liteOrm == null) {
DataBaseConfig config = new DataBaseConfig(context, "tsb.db");
config.debugged = true; // open the log
config.dbVersion = 1; // set database version
liteOrm = LiteOrm.newSingleInstance(config);
}
liteOrm.setDebugged(true); // open the log
}
示例12: queryByEqual
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public <T> ArrayList<T> queryByEqual(String column, Object keyword, Class<T> clazz, boolean asc, String ascKey) {
LiteOrm lOrm = liteOrm.single();
if (TextUtils.isEmpty(ascKey)) {
return lOrm.query(new QueryBuilder<>(clazz).whereEquals(column, keyword));
}
if (asc) {
return lOrm.query(new QueryBuilder<>(clazz).whereEquals(column, keyword).appendOrderAscBy(ascKey));
} else {
return lOrm.query(new QueryBuilder<>(clazz).whereEquals(column, keyword).appendOrderDescBy(ascKey));
}
}
示例13: init
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public static void init(Context context) {
sLiteOrm = LiteOrm.newSingleInstance(context, DB_NAME);
if (BuildConfig.DEBUG) {
sLiteOrm.setDebugged(true);
}
// sLiteOrm = LiteOrm.newCascadeInstance(context, DB_NAME);
// sLiteOrm.setDebugged(true);
}
示例14: testLargeScaleCascadeLiteOrm
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
public static void testLargeScaleCascadeLiteOrm(LiteOrm liteOrm, int max) {
boolean logPrint = OrmLog.isPrint;
OrmLog.isPrint = false;
// 1. 初始化数据
Boss boss = new Boss();
boss.setAddress("ZheJiang Xihu ");
boss.setPhone("1860000");
boss.setName("boss");
boss.setList(new ArrayList<Man>());
for (int i = 0; i < max; i++) {
boss.getList().add(new Man(0, "test", i, false));
}
long num = 0;
// 2. 全部插入测试
long start = System.currentTimeMillis();
num = liteOrm.save(boss);
long end = System.currentTimeMillis();
Log.i(TAG, " lite-orm insert boss model num: " + num + " , use time: " + (end - start) + " MS");
// 5. 删除全部测试
start = System.currentTimeMillis();
// direct delete all faster
num = liteOrm.deleteAll(Boss.class);
// delete list
//num = liteOrm.delete(list);
end = System.currentTimeMillis();
Log.i(TAG, " lite-orm delete boss model num: " + num + " , use time: " + (end - start) + " MS");
OrmLog.isPrint = logPrint;
}
示例15: onCreate
import com.litesuits.orm.LiteOrm; //导入依赖的package包/类
/**
* 在{@link com.litesuits.orm.samples.BaseActivity#onCreate(android.os.Bundle)}中设置视图
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setSubTitile(getString(R.string.sub_title));
mockData();
if (liteOrm == null) {
DataBaseConfig config = new DataBaseConfig(this, "liteorm.db");
config.debugged = true; // open the log
config.dbVersion = 1; // set database version
config.onUpdateListener = null; // set database update listener
liteOrm = LiteOrm.newSingleInstance(config);
}
}