SQLiteReadOnlyDatabaseException: attempt to write a readonly database

后端 未结 3 2040
暖寄归人
暖寄归人 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 01:03

    You need to make a writable database if you want to insert values in database need to add these lines in constructor

    DBHelper helper = new DBHelper (mCtx);
                    this.db = helper.getWritableDatabase();
    
          public Restaurant(Context c)
    {   
        myContext = c;
    
                    DBHelper helper = new DBHelper (mCtx);
                this.db = helper.getWritableDatabase();
    }           
    

提交回复
热议问题