【问题标题】:Android API version 27 still using SQLite 3.8. How to update to SQLite Database 3.19?Android API 版本 27 仍使用 SQLite 3.8。如何更新到 SQLite 数据库 3.19?
【发布时间】:2020-12-15 21:27:39
【问题描述】:

我有一个与 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 以来有什么变化吗?这里可能出了什么问题?

【问题讨论】:

  • 之前试用的是什么版本的Android,现在试用的是什么版本?
  • @Andrew Android 6.0 版。之前和之后。有一个特定的设备需要它。我要做的就是修改它以便它可以与我们的模型一起使用

标签: java android sqlite android-studio


【解决方案1】:

升级到 API 版本 30 解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-01
    相关资源
    最近更新 更多