[英]Android API version 27 still using SQLite 3.8. How to update to SQLite Database 3.19?
我有一个与访问管理 SDK 和设备一起购买的旧项目。 我需要捕获用户数据并发送到 firebase。
所以我所做的是首先升级 sdk 版本,因为它太旧(22)并且 firebase 在我更新之前无法使用它。
简而言之,sqlite 代码在更新前后运行良好,本地数据库一直在崩溃应用程序说:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.fgtit.access/com.fgtit.access.MainActivity}:
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not
open database
下面是创建数据库和操作它的内容。
public static boolean IsFileExists(String filename){
File f=new File(filename);
if(f.exists()){
Log.d("UserDB", f.getName());
return true;
}
return false;
}
public void LoadAll(Context ctx){
usersList.clear();
String optionalPath ="/OnePass/users.db";
String rootPath = ctx.getExternalFilesDir(optionalPath).getAbsolutePath();
if(IsFileExists(rootPath )){
db=SQLiteDatabase.openOrCreateDatabase(rootPath,null);
}else{
db=SQLiteDatabase.openOrCreateDatabase(rootPath,null);
String sql="CREATE TABLE TB_USERS(userid INTEGER PRIMARY KEY ASC,"
+ "usertype INTEGER,"
+ "groupid INTEGER,"
+ "username CHAR(24),"
+ "expdate BLOB,"
+ "enlcon1 BLOB,"
+ "enlcon2 BLOB,"
+ "enlcon3 BLOB,"
+ "fp1 BLOB,"
+ "fp2 BLOB,"
+ "fp3 BLOB,"
+ "enllNO BLOB);";
db.execSQL(sql);
}
Below is my gradle configuration
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.fgtit.access"
versionCode 9
versionName "2.7"
minSdkVersion 17
targetSdkVersion 30
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('libs/android-core-3.1.1-SNAPSHOT.jar')
implementation files('libs/core-3.1.1-SNAPSHOT.jar')
}
自 sdk 22 以来有什么变化吗?这里有什么问题?
升级到 API 版本 30 解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.