samedi 4 juillet 2015

cant update SQLite data base query

I got a problem with trying to update a query in SQLite in android studio.

I have this array of followers and I transform it to a string with space separating every item in the list, so next time that I will want to retrieve the list back it will be easy to change it back to an actual array list again.

I tried following the android developers tutorial and my teacher's tutorial and it still gives me the error message.

here's my code:

    public static void updateFollowersArray(SQLiteDatabase db, UserClass user) {

    String where = USER_TABLE_USER_NAME + " = ?";
    String[] args = {user.get_userName()};

    ContentValues values = new ContentValues();


    ArrayList<String> tempFollowersArray = user.getFollowersArray();

    String tempFollowersString = new String();
    if(tempFollowersArray!=null){
        for (String follower : tempFollowersArray) {
            tempFollowersString += follower + " ";
        }
    }

    values.put(USER_TABLE_FOLLOWERS_ARRAY, tempFollowersString);

    if (db.update(USER_TABLE, values, where, args) < 1) {
        Log.e("updateSQLfollowersArray", "FAILED");
    } else
        Log.e("updateSQLfollowersArray", "SUCCEED");
}

Aucun commentaire:

Enregistrer un commentaire