2014-12-29 38 views
0

我無法理解,爲什麼此方法不更新數據庫,同時不會引發錯誤或異常。數據庫更新以靜默方式失敗

public void updatelocation(String newloc, String cservice, String cno) { 
    try { 
     SQLiteDatabase sdb = getWritableDatabase(); 
     String where = Table_info.Courier_service+ " LIKE ? AND "+Table_info.Courier_no +" LIKE ?"; 
     String[] whereArgs = new String[]{"BLUE DART","BD01"}; 
     System.out.println(whereArgs); 
     ContentValues cv = new ContentValues(); 
     cv.put(Table_info.Location, newloc); 
     sdb.update(Table_info.Table_Name, cv, where, whereArgs); 
     Log.v("server Data", "Updation Successful"); 
     sdb.close(); 
    } catch(Exception e) { 
     System.out.println("update method error:"+e.getMessage()); 
    } 
} 
+0

你沒有說編程語言。我認爲它可能是Java並標記爲這樣;如果我錯了,請糾正它。 –

+0

對不起,我忘了,但它是在Android ....感謝您的任何幫助。 –

回答

2

你的方法似乎很好。你可以打印受影響的行數並查看它說的數字。

sdb.update(Table_info.Table_Name, cv, where, whereArgs); 

此方法將返回受影響的行數。如果它說'0',那麼你的狀況出現問題。