版权声明:随便转都是学别人的 https://blog.csdn.net/weixin_35691921/article/details/84994803
没有系统的知识点,后续补充。
1. ON CONFLICT REPLACE
2. SQLiteStatement
/**
* 使用SQLiteStatement的executeInsert方法插入数据
* @return 返回执行所需要的时间
*/
public long insertStatement() {
long start = System.currentTimeMillis();
for(User user:users){
SQLiteStatement statement = db.compileStatement(sql_insert.toString());
statement.bindString(1, user.getName());
statement.bindLong(2, user.getGender());
statement.bindLong(3, user.getAge());
statement.bindString(4, user.getPhoneNumber());
statement.bindString(5, user.getAddress());
statement.executeInsert();
}
long end = System.currentTimeMillis();
return end - start;
}
3. DROP TABLE IF EXISTS
/**
* @method: dropTable
* @description: 如果数据库中存在xxx_book表,就把它从数据库中drop掉。
* 备份sql中一般都有这样的语句,如果是数据库中有这个表,先drop掉,
* 然后create表,然后再进行数据插入。
* @date: 2018/12/13 16:28
*/
void dropTable(SQLiteDatabase db, String table) {
db.execSQL("DROP TABLE IF EXISTS " + table);
}
4. 数据库,基本父类回调时机
5. Uri.withAppendedPath(tableUri, name)
根据表的Uri和对应key name生成全新的Uri