The Android database is always not updated with update updates, and no exceptions are thrown!

Source: Internet
Author: User

============ Problem Description ============


The data can't be updated! I don't know what the problem is. The great God came in and looked. The return is always false!
The code is attached!
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;
}

============ Solution 1============


Long B = db.update ("User", CV, "useraccount=" +useraccount, New string[]{}); This error, update is not so used, should be changed to
Long B = db.update ("User", CV, "useraccount=?", New String[]{useraccount});

============ Solution 2============


The whole picture should not be stored in the database, the path to save the picture is better.

The Android database is always not updated with update updates, and no exceptions are thrown!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.