Code example for SQLiteDatabase

Methods: queryupdate

0
	 * rowId for that note, otherwise return a -1 to indicate failure. 
	 */ 
	public long createHighscore(String name, int score) {
		 
		ContentValues initialValues = createContentValues(name, score);
		Cursor mCursor = database.query(DATABASE_TABLE, new String[] { KEY_ROWID,
				KEY_NAME, KEY_SCORE}, null, null, null,
				null, KEY_SCORE + " DESC");
		 
		// Only store the best 10 highscores 
		if(mCursor.getCount() == 10) {
			// Check whether the lowest score so far is lower than the current score 
			mCursor.moveToLast();
			int index = mCursor.getColumnIndex(KEY_SCORE);
			int oldScore = mCursor.getInt(index);
			int id = mCursor.getInt(mCursor.getColumnIndex(KEY_ROWID));
			if(score > oldScore) {		
				return database.update(DATABASE_TABLE, initialValues, KEY_ROWID + "="
						+ id, null);
			} 
		} else { 
			return database.insert(DATABASE_TABLE, null, initialValues);
		} 
Connect your IDE to all the code out there  Get Codota for Java