java - Android API 版本 27 仍使用 SQLite 3.8。如何更新到 SQLite 数据库 3.19?
问题描述
我有一个与 Access Management 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 解决了这个问题。
推荐阅读
- angular - *ngIf - 引用需要多次设置的属性
- c# - 在多种移动分辨率下保持相同的相机视图
- java - 从站:错误:未设置 JAVA_HOME 并且找不到[集群设置]
- r - 将 xtable 和 ggplot2 输出并排放置在 Beamer 中
- r - ggplot 填充 SpatialPolygonsDataFrame
- typo3 - 错字3更新后 - 文字不环绕图像,图像不显示在列中
- java - google guice 在 android 项目中不起作用
- angular - Angular2 +单选按钮不可点击
- reactjs - 分组特定子组件 React
- mysql - MySQL - SELECT 和 GROUP BY 的问题