有人可以向我解釋這段代碼是如何工作的以及我如何將這些數據插入到數據庫中?我的Java有兩個Java文件。第一段代碼位於第一個Java文件中,第二段位於第二個Java文件中。爲什麼我傳遞以下參數ImageID,currentDay,v.getID。那麼當我調用insertNewRoutine函數時,它使用的參數是int activityResourceID,String day和int slot?困惑爲什麼它使用?提前致謝!任何人都可以解釋這個代碼如何將數據插入數據庫?
boolean routineInserted = myDb.insertNewRoutine(ImageID, currentDay, v.getId());
if (routineInserted == true) {
Toast.makeText(MondayRoutineEdit.this, "Activity Inserted", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MondayRoutineEdit.this, "Activity Not Inserted", Toast.LENGTH_LONG).show();
}
public boolean insertNewRoutine(int activityResourceID, String day, int slot)
{
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM " + RoutineTable + " WHERE DayID ='" + day + "' AND SlotID =" + slot);
ContentValues contentValues = new ContentValues();
contentValues.put(RoutineColumn2, day);
contentValues.put(RoutineColumn3, activityResourceID);
contentValues.put(RoutineColumn4, slot);
long result = db.insert(RoutineTable, null, contentValues);
if (result == -1)
return false;
else
return true;
}
對不起我的意思是我爲什麼通過以下參數圖像標識,CURRENTDAY,v.getID。那麼當我調用insertNewRoutine函數時,它使用的參數是int activityResourceID,String day和int slot?困惑爲什麼它使用? –