List of usage examples for android.database.sqlite SQLiteCursor getInt
@Override public int getInt(int columnIndex)
From source file:com.gmail.taneza.ronald.carbs.myfoods.MyFoodsEditableFragment.java
private FoodItem getFoodItemAtPosition(ListView l, int position) { SQLiteCursor cursor = (SQLiteCursor) l.getItemAtPosition(position); return new FoodItem(cursor.getString(cursor.getColumnIndexOrThrow(FoodDbAdapter.COLUMN_TABLE_NAME)), cursor.getInt(cursor.getColumnIndexOrThrow(FoodDbAdapter.MYFOODS_COLUMN_ID)), cursor.getInt(cursor.getColumnIndexOrThrow(FoodDbAdapter.MYFOODS_COLUMN_QUANTITY_PER_UNIT))); }
From source file:com.chess.genesis.data.GameDataDB.java
public int getUnreadMsgCount() { final String username = getUsername(); final String[] data = { username, username }; final String query = "SELECT COUNT(*) FROM msgtable WHERE unread=1 AND (username=? OR opponent=?)"; final SQLiteCursor cursor = (SQLiteCursor) db.rawQuery(query, data); try {//from w w w. j a va 2 s . c o m cursor.moveToFirst(); return cursor.getInt(0); } finally { cursor.close(); } }
From source file:com.chess.genesis.data.GameDataDB.java
public int getUnreadMsgCount(final String gameid) { final String[] data = { gameid }; final SQLiteCursor cursor = (SQLiteCursor) db .rawQuery("SELECT COUNT(unread) FROM msgtable WHERE unread=1 AND gameid=?", data); try {/* w ww. j a va 2 s. co m*/ cursor.moveToFirst(); return cursor.getInt(0); } finally { cursor.close(); } }
From source file:com.chess.genesis.data.GameDataDB.java
public void recalcYourTurn() { final String username = getUsername(); final String[] data = { username, username }; final String query = "SELECT gameid, status, history, white, drawoffer FROM onlinegames WHERE white=? or black=?;"; final SQLiteCursor cursor = (SQLiteCursor) db.rawQuery(query, data); cursor.moveToFirst();//from www .j a v a 2 s . c o m for (int i = 0, len = cursor.getCount(); i < len; i++) { final String gameid = cursor.getString(0); final int status = cursor.getInt(1); final String history = cursor.getString(2); final String white = cursor.getString(3); final int drawoffer = cursor.getInt(4); final GameInfo info = new GameInfo(context, status, history, white, drawoffer); final Object[] data2 = { info.getYourTurn(), gameid }; db.execSQL("UPDATE onlinegames SET yourturn=? WHERE gameid=?;", data2); cursor.moveToNext(); } cursor.close(); }