当前位置: 首页>>代码示例>>Java>>正文


Java FlowManager.getDatabase方法代码示例

本文整理汇总了Java中com.raizlabs.android.dbflow.config.FlowManager.getDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java FlowManager.getDatabase方法的具体用法?Java FlowManager.getDatabase怎么用?Java FlowManager.getDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.raizlabs.android.dbflow.config.FlowManager的用法示例。


在下文中一共展示了FlowManager.getDatabase方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
/**
 * 新增或者修改数据库的统一方法
 * @param tClass 传递一个class信息
 * @param models 这个class对应的实例的数组
 * @param <Model> 这个实例的泛型 限定条件是BaseModel
 */
public static<Model extends BaseModel> void save(final Class<Model> tClass, final Model... models) {
    if (models==null||models.length==0) return;
    // 当前数据库的一个管理者
    DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
    // 提交一个事务
    definition.beginTransactionAsync(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // 执行
            ModelAdapter<Model> adapter = FlowManager.getModelAdapter(tClass);
            // 保存
            adapter.saveAll(Arrays.asList(models));
            // 唤起通知
            instance.notifySave(tClass,models);
        }
    }).build().execute();
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:24,代码来源:DbHelper.java

示例2: delete

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
/**
 * 删除数据库的的统一方法
 * @param tClass 传递一个class信息
 * @param models 这个class对应的实例的数组
 * @param <Model> 这个实例的泛型 限定条件是BaseModel
 */
public static<Model extends BaseModel> void delete(final Class<Model> tClass, final Model... models) {
    if (models==null||models.length==0) return;
    // 当前数据库的一个管理者
    DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
    // 提交一个事务
    definition.beginTransactionAsync(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // 执行
            ModelAdapter<Model> adapter = FlowManager.getModelAdapter(tClass);
            // 删除
            adapter.deleteAll(Arrays.asList(models));
            // 唤起通知
            instance.notifyDelete(tClass,models);
        }
    }).build().execute();
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:24,代码来源:DbHelper.java

示例3: updateGroup

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
/**
 * 从成员中找出成员对应的群,并对群进行更新
 *
 * @param members 群成员列表
 */
private void updateGroup(GroupMember... members) {
    // 不重复集合
    final Set<String> groupIds = new HashSet<>();
    for (GroupMember member : members) {
        // 添加群Id
        groupIds.add(member.getGroup().getId());
    }

    // 异步的数据库查询,并异步的发起二次通知
    DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
    definition.beginTransactionAsync(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // 找到需要通知的群
            List<Group> groups = SQLite.select()
                    .from(Group.class)
                    .where(Group_Table.id.in(groupIds))
                    .queryList();

            // 调用直接进行一次通知分发
            instance.notifySave(Group.class, groups.toArray(new Group[0]));

        }
    }).build().execute();
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:31,代码来源:DbHelper.java

示例4: upDataBySynchronous

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
public static void upDataBySynchronous(final ArrayList<SOListBean.ListBean> mListBeans, final String type){
    DatabaseDefinition database = FlowManager.getDatabase(LueansDB.class);
    database.executeTransaction(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // do something here
            deleteSoDdata(type);
            saveSoData(mListBeans,type);
        }
    });
}
 
开发者ID:lueans,项目名称:LueansRead,代码行数:12,代码来源:SoDao.java

示例5: deleteSQLiteMetadata

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
/**
 * This method removes the sqlite_sequence table that contains the last autoincrement value for
 * each table
 */
private void deleteSQLiteMetadata() {
    String sqlCopy = "Delete from sqlite_sequence";
    DatabaseDefinition databaseDefinition =
            FlowManager.getDatabase(AppDatabase.class);
    databaseDefinition.getWritableDatabase().execSQL(sqlCopy);

}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:12,代码来源:LocalPullController.java

示例6: saveAllItems

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
protected static void saveAllItems(final List<Model> models) {
    DatabaseDefinition databaseDefinition =
            FlowManager.getDatabase(AppDatabase.class); // execute  transaction
    databaseDefinition.executeTransaction(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            for (Model model : models) {
                model.insert();
            }
        }
    });
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:13,代码来源:PopulateDB.java

示例7: saveBatch

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
public static void saveBatch(final List<Model> insertModels) {
    //Save questions in batch

    DatabaseDefinition databaseDefinition =
            FlowManager.getDatabase(AppDatabase.class);
    databaseDefinition.executeTransaction(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            for (Model model : insertModels) {
                model.insert();
            }
        }
    });
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:15,代码来源:SdkQueries.java

示例8: deleteSQLiteMetadata

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
/**
 * This method removes the sqlite_sequence table that contains the last autoincrement value for
 * each table
 */
private static void deleteSQLiteMetadata() {
    String sqlCopy = "Delete from sqlite_sequence";
    DatabaseDefinition databaseDefinition =
            FlowManager.getDatabase(AppDatabase.class);
    databaseDefinition.getWritableDatabase().execSQL(sqlCopy);

}
 
开发者ID:EyeSeeTea,项目名称:pictureapp,代码行数:12,代码来源:PopulateDB.java

示例9: getDatabase

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
@NonNull
protected DatabaseDefinition getDatabase() {
    if (database == null) {
        database = FlowManager.getDatabase(getDatabaseName());
    }
    return database;
}
 
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:8,代码来源:BaseContentProvider.java

示例10: getData

import com.raizlabs.android.dbflow.config.FlowManager; //导入方法依赖的package包/类
public ArrayList<Cursor> getData(String Query){
    //get writable database
    // TODO: Add Your Database Class Here
    if (myClass == null)
    {
        throw new RuntimeException("myClass is not initialized yet!");
    }

    FlowSQLiteOpenHelper fom = new FlowSQLiteOpenHelper(FlowManager.getDatabase(myClass), null);

    //SQLiteDatabase sqlDB = this.getWritableDatabase();
    SQLiteDatabase sqlDB = fom.getWritableDatabase();

    String[] columns = new String[] { "mesage" };
    //an array list of cursor to save two cursors one has results from the query
    //other cursor stores error message if any errors are triggered
    ArrayList<Cursor> alc = new ArrayList<Cursor>(2);
    MatrixCursor Cursor2= new MatrixCursor(columns);
    alc.add(null);
    alc.add(null);


    try{
        String maxQuery = Query ;
        //execute the query results will be save in Cursor c
        Cursor c = sqlDB.rawQuery(maxQuery, null);


        //add value to cursor2
        Cursor2.addRow(new Object[] { "Success" });

        alc.set(1,Cursor2);
        if (null != c && c.getCount() > 0) {


            alc.set(0,c);
            c.moveToFirst();

            return alc ;
        }
        return alc;
    } catch(SQLException sqlEx){
        Log.d("printing exception", sqlEx.getMessage());
        //if any exceptions are triggered save the error message to cursor an return the arraylist
        Cursor2.addRow(new Object[] { ""+sqlEx.getMessage() });
        alc.set(1,Cursor2);
        return alc;
    } catch(Exception ex){

        Log.d("printing exception", ex.getMessage());

        //if any exceptions are triggered save the error message to cursor an return the arraylist
        Cursor2.addRow(new Object[] { ""+ex.getMessage() });
        alc.set(1,Cursor2);
        return alc;
    }


}
 
开发者ID:wajahatkarim3,项目名称:DBFlowManager,代码行数:60,代码来源:DBFlowManagerActivity.java


注:本文中的com.raizlabs.android.dbflow.config.FlowManager.getDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。