Skip to content Skip to sidebar Skip to footer

Android Sqlite Queries Marked As Error By Android Studio

In one of my Android apps I use some SQLite queries that are starting to give problems since I've updated to Android Studio 3.0. Despite I can compile and run the app they are mark

Solution 1:

@Wonton Here is a suggestion use MVP design this is where you have a Database Model where you have a bunch of get and set for each item in the database table. Next handle all your CRUD in an Activity called DBHelper then you can make calls to it from any other Activity with a lot less chance of errors. YES I use db.execSQL but once you have the string to update or insert in DBHelper life is good Here is an example of code from a DBHelper Activity HINT read about MVP

    /* Update Record in Database*/
public void updateDBRow(String rowid,String website, String username, String password, String question,String answer, String notes){

    db = this.getWritableDatabase();
    ContentValues cv = new ContentValues();

    cv.put(Col_WS,website);
    cv.put(Col_UN,username);
    cv.put(Col_PW,password);
    cv.put(Col_SQ,question);
    cv.put(Col_SA,answer);
    cv.put(Col_NOTES,notes);

    /*NOTE WHERE THE quotation MARKS ARE */
    db.update(TABLE_INFO,cv, Col_ID + " = ?",new String[] { rowid });
    db.close();
}

Post a Comment for "Android Sqlite Queries Marked As Error By Android Studio"