Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 数据库自动更新失败_Java_Android_Sqlite - Fatal编程技术网

Java 数据库自动更新失败

Java 数据库自动更新失败,java,android,sqlite,Java,Android,Sqlite,我无法理解为什么这个方法在没有抛出错误或异常的情况下不更新数据库 public void updatelocation(String newloc, String cservice, String cno) { try { SQLiteDatabase sdb = getWritableDatabase(); String where = Table_info.Courier_service+ " LIKE ? AND "+Table_info.Couri

我无法理解为什么这个方法在没有抛出错误或异常的情况下不更新数据库

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());
    }
}

你的方法似乎很好。您是否可以打印受影响的行数,并查看其显示的行数

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

此方法将返回受影响的行数。如果它显示“0”,则您的where条件有问题。

您没有说编程语言。我认为它可能是Java,并被标记为Java;如果我错了,请更正。对不起,我忘了,但它是安卓系统的。谢谢你的帮助。