public void deleteFav(MainPageItem qy) { Cursor cursor = null; String where = FavTable.USER_ID + " = '" + MyApplication.getInstance().getCurrentUser().getObjectId() + "' AND " + FavTable.OBJECT_ID + " = '" + qy.getObjectId() + "'"; cursor = dbHelper.query(DBHelper.TABLE_NAME, null, where, null, null, null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); int isLove = cursor.getInt(cursor.getColumnIndex(FavTable.IS_LOVE)); if (isLove == 0) { dbHelper.delete(DBHelper.TABLE_NAME, where, null); } else { ContentValues cv = new ContentValues(); cv.put(FavTable.IS_FAV, 0); dbHelper.update(DBHelper.TABLE_NAME, cv, where, null); } } if (cursor != null) { cursor.close(); dbHelper.close(); } }
public boolean updateStatus(int ID, String status) { // TODO Auto-generated method stub ContentValues values = new ContentValues(); values.put(GTDSTATUS, status); helper.update(TABLE_NAME, values, "smsID=?", new String[] {String.valueOf(ID)}); return false; }
public long insertFav(MainPageItem qy) { long uri = 0; Cursor cursor = null; String where = FavTable.USER_ID + " = '" + MyApplication.getInstance().getCurrentUser().getObjectId() + "' AND " + FavTable.OBJECT_ID + " = '" + qy.getObjectId() + "'"; cursor = dbHelper.query(DBHelper.TABLE_NAME, null, where, null, null, null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); ContentValues conv = new ContentValues(); conv.put(FavTable.IS_FAV, 1); conv.put(FavTable.IS_LOVE, 1); dbHelper.update(DBHelper.TABLE_NAME, conv, where, null); } else { ContentValues cv = new ContentValues(); cv.put(FavTable.USER_ID, MyApplication.getInstance().getCurrentUser().getObjectId()); cv.put(FavTable.OBJECT_ID, qy.getObjectId()); cv.put(FavTable.IS_LOVE, qy.getMyLove() == true ? 1 : 0); cv.put(FavTable.IS_FAV, qy.getMyFav() == true ? 1 : 0); uri = dbHelper.insert(DBHelper.TABLE_NAME, null, cv); } if (cursor != null) { cursor.close(); dbHelper.close(); } return uri; }