SQLiteReadOnlyDatabaseException: attempt to write a readonly database

后端 未结 3 1999
暖寄归人
暖寄归人 2021-01-22 00:00

Just changed my data that are hard-code into database to using SQLite Database Browser. Before I changed all my query works fine but errors occurs when I changed. I can\'t do th

3条回答
  •  别那么骄傲
    2021-01-22 00:52

    public void openDataBase() throws SQLException{
    
        //Open the database
        String myPath = DB_PATH + DATABASE_NAME;
        ourDatabase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
    
    }
    

    You must change SQLiteDatabase.OPEN_READONLY to SQLiteDatabase.OPEN_READWRITE, because OPEN_READONLY only allows to read not write.

提交回复
热议问题