20140508
1. SQL statement, splicing query, adding single quotation marks for the string type, using =, and directly assigning values for the integer type
// Method 1
String SQL = "select ID, name from table_temp where name = 'host' Limit 30 offset 20 ";
DB. rawquery (SQL, null );
// Method 2 can I say it is not verified?
String SQL = "select ID, name from table_temp where name =? Limit? Offset? "
DB. rawquery (SQL, new string [] {name_value, limit_value, offset_value });
2. fuzzy query, using like, % placeholder
Three methods of fuzzy search
// Method 1
String SQL = "select ID, name from table_temp where name like '%" + keyValue + "' % ";
DB. rawquery (SQL, null );
// Method 2 not verified
String SQL = "select ID, name from table_temp where name like? ";
DB. rawquery (SQL, new string [] {keyValue });
3. Obtain the data in the returned value of cursor.
Problems encountered in the code today
Android. database. cursorindexoutofboundsexception: Index-1 requested, with a size of 1
I always thought it was a column query problem.
Google discovered that the subscript returned by cursor by default is-1. Before the value is set, move the subscript to a place with a return value.
After adding cursor. movetofirst (), there is no problem.
Explanation and stackoverflow description
4. I have to say that there is another more important thing today, and it is planted again under break.
In the switch case, the break is missing;
Traps that have been filled together in those years