不是原创、转载自他人
批量地插入数据的方法 转载自:https://www.jianshu.com/p/a3aae513939b
解决由隐式事务开启的消耗!主动地开启事务
//假设strings.size() = 10000
try {
mDb.beginTransaction();
for (String data : strings) {
ContentValues contentValues = new ContentValues();
if(!TextUtils.isEmpty(data)){
contentValues.put(key, data);
}
mDb.insert(table_name, null, contentValues);
}
mDb.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
mDb.endTransaction();
mDb.close();
}
建立数据库索引、优化查询
转载自: https://blog.csdn.net/chu_qun/article/details/3719532
超级详细的Assets解释
转载自: https://blog.csdn.net/u012005313/article/details/71268254
gradle技巧
配置国内的源、加快下载
// Top-level build file where you can add configuration options common to all sub-projects/modules.
//
//buildscript {
// repositories {
// google()
// jcenter()
//
// }
// dependencies {
// classpath 'com.android.tools.build:gradle:3.5.2'
//
// // NOTE: Do not place your application dependencies here; they belong
// // in the individual module build.gradle files
// }
//}
//
//allprojects {
// repositories {
// google()
// jcenter()
//
// }
//}
//
//
//task clean(type: Delete) {
// delete rootProject.buildDir
//}
buildscript {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}