In Android, operations on the database may result in errors from time to time, and sometimes it takes only half a day to find the real reason. Here, I will record my experiences.
1,Bad request for field slot 0,-1. numrows = 2, numcolumns = 14
Java. Lang. illegalstateexception: Get field slot from row 0 col-1 failed
(1) The reason is that the field name you added to the database is different from the field name used for query (that is, the word is wrong, including case and space ). This error is easy to find.
(2 .)Before passing the cursor object, I had a problem with the query condition of the cursor. If I did not write a certain column, then I encountered the problem shown above. Then I changed the query condition so that it would be okay.
Private Static final string [] underlying_columns = new string [] {downloads. impl. _ id, downloads. impl. _ DATA + "as" + column_local_filename, downloads. column_title, downloads. column_description, downloads. column_uri, downloads. column_mime_type, downloads. impl. _ DATA };
Public cursor query (query) {cursor underlyingcursor = query. runquery (mresolver, underlying_columns, mbaseuri); If (underlyingcursor = NULL) {return NULL;} return New cursortranslator (underlyingcursor, mbaseuri );}
MainIs the collection of the above fields during the query (Underlying_columns) You write less fields to be queried, for example:
If you are notUnderlying_columns
Downloads. impl. _ data field. If you use this field in subsequent operations, this error will occur.
I encountered such an error. It took two hours to find the cause... Time is so expensive !!!!!
2,