I tried both "long" and "int" in the code and both have the same results. What am I doing wrong?
Here is the relevant database helper class code:
- Code: Select all
public long createNote(String username, String comment, int playerscore) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_username, username);
initialValues.put(KEY_comment, comment);
initialValues.put(KEY_score, playerscore);
return mDb.insert(DATABASE_TABLE, null, initialValues);
}
public Cursor fetchNote(long rowId) throws SQLException {
Cursor result = mDb.query(true, DATABASE_TABLE, new String[] {
KEY_ROWID, KEY_username, KEY_comment, KEY_score}, KEY_ROWID + "=" + rowId, null, null,
null, null);
if ((result.count() == 0) || !result.first()) {
throw new SQLException("No note matching ID: " + rowId);
}
return result;
}
And here is the relevant code from the class that is using the database to store and retrieve info:
- Code: Select all
dbhelper.createNote(userName, userComment, score);
- Code: Select all
Cursor c = dbhelper.fetchNote(userNumber);
thisusersname = c.getString(c.getColumnIndex(dbhelper.KEY_username));
thisuserscomment = c.getString(c.getColumnIndex(dbhelper.KEY_comment));
thisuserscore = c.getInt(c.getColumnIndex(dbhelper.KEY_score));

