2014-12-29 37 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',那么你的状况出现问题。