Android 数据库 在使用 update更新的时候,总是无法更新,还没有异常抛出!

============问题描述============


数据更新不了!不知道问题出在那了 。大神进来看看呗。 返回的总是false!
代码附上了!
public boolean update(String userAccount,String username,Drawable uInfo) {
byte[] picture = PictureTurn.Bitmap2Bytes(PictureTurn
.drawable2Bitmap(uInfo));
System.out.println("----------------->"+picture);
System.out.println("----------userAccount------->"+userAccount);

boolean result = false;
db = sqa.getReadableDatabase();
cv = new ContentValues();
    cv.put("userAccount", userAccount);
    cv.put("username", username);
cv.put("picture", picture);
long b = db.update("user", cv, "userAccount="+userAccount,
new String[]{});
if (b > 0) {
result = true;
}
db.close();
return result;
}

============解决方案1============


long b = db.update("user", cv, "userAccount="+userAccount, new String[]{});这句错误,update不是这么用的,应该改为
long b = db.update("user", cv, "userAccount=?", new String[]{userAccount});

============解决方案2============


不应该将整张图片存入数据库,存图片的路径比较好。
posted @ 2014-10-19 21:54  android教程  阅读(589)  评论(0编辑  收藏  举报
我要啦免费统计