2013-07-05 43 views
0

我想在數據庫表中搜索具有int值而不是字符串值的行,但是當我這樣做時出現錯誤。所以,我想,但是我能做到這一點是不可能的:如何搜索int而不是字符串,sqlite數據庫,android

updateRow(int titleCode, int questionCode, int inspectionResult){ 

所以不是我堅持這一點,

updateRow(String titleCode, String questionCode, int inspectionResult){ 

我如何使用選擇ARGS這樣;

new String[]{titleCode, questionCode} 

要搜索titleCode和questionCode,如果這些變量是int/integer而不是String?

的事實,我不能從一個String類型的選擇args數組更改爲int類型但我想在數據庫表來搜索INT值基於部分

  public void updateRow(String titleCode, String questionCode, int inspectionResult){ 

      ContentValues contentValues = new ContentValues(); 
      String selection = "INSPECTION_PLACE_CODE = ? AND INSPECTION_ITEM_CODE = ?"; 
      contentValues.put(INSPECTION_RESULT_JUDGEMENT, inspectionResult); 
      sqLiteDatabase.update(DETAILS_TRAN_SMALL_INSPECTION_RESULTS, contentValues, selection, 
      new String[]{titleCode, questionCode}); 

     } 

回答

1

https://www.sqlite.org/datatype3.html

3.3,比較,包括平等檢查受類型親和力影響。您可以安全地將int值作爲SQLite中的字符串進行測試,因爲在比較之前,數據庫驅動程序會自動將您的字符串轉換爲int。

相關問題