0

私はずっと前に私たちのプロジェクトにsqlcipherを統合しました。セキュリティ上の問題により、sqlcipher のバージョンをアップグレードする必要があります。私はこれの下のリンクを見てきました

  1. https://discuss.zetetic.net/t/migrating-from-sqlcipher-3-5-1-to-4-1-3-in-android/3652
  2. https://discuss.zetetic.net/t/upgrading-sqlcipher-for-android-from-3-to-4/3580

しかし、そのコードをどこに追加すればよいかわかりません。それらのコードを私のコードと統合するにはどうすればよいですか。

これは私の Logcat です

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.axis.leadsloans, PID: 8798
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.axis.leadsloans/com.axis.leadsloans.nnmnu}: net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2928)
Caused by: net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;

これは私のデータベース関連のコードです。

public class CRMDB {
    private SQLiteHelper sqLiteHelper;
    public SQLiteDatabase sqLiteDatabase;
    private Context context;
    .
    .
    .

    public CRMDB(Context c) {
        context = c;
        String s = "";
        SQLiteDatabase.loadLibs(c);
        SharedPreferences prefs = c.getSharedPreferences(Constants.PREFERENCE_NAME, Activity.MODE_PRIVATE);
        empid = prefs.getString("empid", "");
    }


    public CRMDB openToWrite() throws SQLiteFullException {
        sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME + "_" + empid + ".db", null, MYDATABASE_VERSION);
        //App get crash on this line
        sqLiteDatabase = sqLiteHelper.getWritableDatabase("password");
        return this;
    }


    public CRMDB openToRead() throws SQLiteFullException {
        sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME + "_" + empid + ".db", null, MYDATABASE_VERSION);
        sqLiteDatabase = sqLiteHelper.getReadableDatabase("password");
        return this;
    }


    public long insertData(String tablename, ContentValues contentvalue) {
        return sqLiteDatabase.insert(tablename, null, contentvalue);
    }

    public Cursor getData(String query) {
        Cursor c = sqLiteDatabase.rawQuery(query, null);
        return c;
    }

    public long updateData(String tablename, ContentValues contentvalue, String where, String whereArgs[]) {
        return sqLiteDatabase.update(tablename, contentvalue, where, whereArgs);
    }

    public class SQLiteHelper extends SQLiteOpenHelper {

        public SQLiteHelper(Context context, String name, CursorFactory factory, int version) {
            super(context, name, factory, version);

        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(tb_task_createtable);
            db.execSQL(tb_calls_createtable);
            db.execSQL(tb_messages_table);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        }
    }
}

これを理解するのを手伝ってください。

4

1 に答える 1