コード例 #1
0
 public static boolean deleteTable(Databases db) {
   try {
     SQLiteDatabase sql = db.getWritableDatabase();
     String query = "DELETE from " + TABLE_NAME;
     LOG.log("Query:", "Query:" + query);
     sql.execSQL(query);
     sql.close();
     return true;
   } catch (Exception e) {
     return false;
   }
 }
コード例 #2
0
 public static boolean inseartOperation(Databases db, FoodItem item) {
   SQLiteDatabase sql = db.getWritableDatabase();
   String query = "";
   query =
       "insert into "
           + TABLE_NAME
           + " ("
           + FOOD_ID
           + ","
           + NAME
           + ","
           + RATE
           + ","
           + DESCRIPTION
           + ","
           + IMAGE_URL
           + ") values ("
           + ""
           + item.id
           + ""
           + ","
           + "'"
           + item.name
           + "'"
           + ","
           + ""
           + item.rate
           + ""
           + ","
           + "'"
           + item.description
           + "'"
           + ","
           + "'"
           + item.imageUrl
           + "'"
           + ");";
   LOG.log("Query:", "Query:" + query);
   sql.execSQL(query);
   return true;
 }
コード例 #3
0
  public static boolean updateOperation(Databases db, FoodItem item) {

    SQLiteDatabase sql = db.getWritableDatabase();
    String query = "";
    query =
        "update "
            + TABLE_NAME
            + " SET "
            + FOOD_ID
            + " = "
            + item.id
            + " , "
            + NAME
            + " = '"
            + item.name
            + "' , "
            + RATE
            + " = "
            + item.rate
            + " , "
            + DESCRIPTION
            + " = '"
            + item.description
            + "' , "
            + IMAGE_URL
            + " = '"
            + item.imageUrl
            + "' "
            + " WHERE "
            + FOOD_ID
            + " = "
            + item.id
            + "";
    LOG.log("Query:", "Query:" + query);
    sql.execSQL(query);

    sql.close();
    return true;
  }