List of usage examples for android.database.sqlite SQLiteCursor getString
@Override public String getString(int columnIndex)
From source file:android.support.v7.testutils.TestUtilsMatchers.java
/** * Returns a matcher that matches data entry in <code>SQLiteCursor</code> that has * the specified text in the specified column. *//* ww w. jav a 2 s . c o m*/ public static Matcher<Object> withCursorItemContent(final String columnName, final String expectedText) { return new BoundedMatcher<Object, SQLiteCursor>(SQLiteCursor.class) { @Override public void describeTo(Description description) { description.appendText("doesn't match " + expectedText); } @Override protected boolean matchesSafely(SQLiteCursor cursor) { return TextUtils.equals(expectedText, cursor.getString(cursor.getColumnIndex(columnName))); } }; }
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 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();/* www .j a va 2s.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(); }
From source file:com.chess.genesis.data.GameDataDB.java
public List<String> getOnlineGameIds() { final String username = getUsername(); final String[] data = { username, username }; final SQLiteCursor cursor = (SQLiteCursor) db .rawQuery("SELECT gameid FROM onlinegames WHERE white=? OR black=?", data); final List<String> list = new ArrayList<String>(cursor.getCount()); cursor.moveToFirst();/* w w w .ja va 2 s. c o m*/ for (int i = 0, len = cursor.getCount(); i < len; i++) { list.add(cursor.getString(0)); cursor.moveToNext(); } cursor.close(); return list; }
From source file:com.chess.genesis.data.GameDataDB.java
public List<String> getArchiveGameIds() { final String username = getUsername(); final String[] data = { username, username }; final SQLiteCursor cursor = (SQLiteCursor) db .rawQuery("SELECT gameid FROM archivegames WHERE white=? OR black=?", data); final List<String> list = new ArrayList<String>(cursor.getCount()); cursor.moveToFirst();/*from w ww.j a va 2 s.c o m*/ for (int i = 0, len = cursor.getCount(); i < len; i++) { list.add(cursor.getString(0)); cursor.moveToNext(); } cursor.close(); return list; }