dimanche 8 novembre 2015

Information does not update in SQLite Database

I've been working on a Login-Register application and is currently facing some problem.

The problem I encountered was that whenever I tried to update the information in the table, instead of updating the table nothing change. No information was inserted nor change.

Does anyone know why and can help? I hope to get help soon as I am doing this for my final year project.

Here is the code I wrote for my update part in the DatabaseHelper.java :

    public int updateRegister(Register reg){
    SQLiteDatabase db = this.getWritableDatabase();

    String query = "select * from register";
    Cursor cursor = db.rawQuery(query, null);
    int count = cursor.getCount();

    ContentValues values = new ContentValues();
    values.put(COLUMN_NAME, reg.getName());
    values.put(COLUMN_AGE, reg.getAge());
    values.put(COLUMN_CONTACT, reg.getContact());
    values.put(COLUMN_ADDRESS, reg.getAddress());
    values.put(COLUMN_UNAME, reg.getUname());
    values.put(COLUMN_PASS, reg.getPass());
    values.put(COLUMN_EMERGENCYCONTACTNAME, reg.getEmergencycontactname());
    values.put(COLUMN_EMERGENCYCONTACTNUMBER, reg.getEmergencycontactnumber());

    return db.update(TABLE_NAME, values, COLUMN_ID + " = ?", new String[] { String.valueOf(cursor.getCount())});
}

Here is the link to my project in case you would like to see the full file: http://ift.tt/1MtMDBo

Thank you.

Aucun commentaire:

Enregistrer un commentaire