joielechong

Sample Using database query

Mar 18th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. public Category getCategory(int categoryId) {
  2.         Cursor c = database.query(DBHelper.TABLE_CATEGORY, allColumns,
  3.                 DBHelper.KEY_NAME + " = " + categoryId, null,
  4.                 null, null, null);
  5.         if (c != null && c.moveToFirst()) {
  6.             category.setId(c.getInt(c.getColumnIndex(DBHelper.KEY_ID)));
  7.             category.setName(c.getString(c.getColumnIndex(DBHelper.KEY_NAME)));
  8.             c.close();
  9.         }
  10.         return category;
  11.     }
Add Comment
Please, Sign In to add comment