Home > database >  SQLite cursor. GetCount ()> 0, but the cursor. MoveToFirst get FALSE
SQLite cursor. GetCount ()> 0, but the cursor. MoveToFirst get FALSE

Time:09-27

My database is that it is only a PIC list, store the image binary code, the column name is picture
 create table PIC (picture Blob) 

Now I have inserted the two data, and then want to read the picture
 Cursor Cursor=db_test. RawQuery (" select picture from PIC ", null); 
If (cursor!=null & amp; & Cursor. GetCount () & gt; 0 {
Toast. MakeText (this, "reads the images success:" + cursor. GetCount (), Toast. LENGTH_SHOW), show ();
}

Show as a result of the "reading pictures success: 2", that is to say, inside there are two data, and cursor has been read, but once to read the data in a cursor is wrong, so I changed the code
 Cursor Cursor=db_test. RawQuery (" select picture from PIC ", null); 
If (cursor!=null & amp; & Cursor. GetCount () & gt; 0 & amp; & Cursor. MoveToFirst ()) {
Toast. MakeText (this, "reads the images success:" + cursor. GetCount (), Toast. LENGTH_SHOW), show ();
}
The else {
Toast. MakeText (this, "reads the images failure", Toast. LENGTH_SHOW), show ();
}

The result is "reading pictures failed", that is to say, cursor. MoveToFirst () returns FALSE, the great god give directions, is this why? Clearly in the cursor has two data, but can't moveToFirst () cannot moveToNext (), over a long time haven't solved,

CodePudding user response:

Pray god help agghh ah ha ~ ~ ~ ~

CodePudding user response:

Pray god help agghh ah ha ~ ~ ~ ~
  • Related