Android and android
1 bug, (sqlite related)
Encountered: attempt to re-open an already-closed object: SQLiteDatabase:/data/com. example. biye/databases/ToDothing. db
Try opening a closed object: sqlitedatabase ......
Solution: Check whether the database is closed in the previous method? For example, comment out or delete db. close.
2. BUG, (EditText value assignment)
Encountered: EditText edit31.setText ("that is, you are not allowed to assign values ");
Study: Error NULL pointer exception nullpointerexception;
Is the id incorrect? 1. <EditText android: id = "@ + id/edit31"/> 2. edit31 = (EditText) findViewById (R. id. edit31); That's right !! Tangle
Find out the cause: edit31 = (EditText) findViewById (R. id. edit31); The position is behind the button event. When the btn event is executed, the program does not assign EditText to edit31 on the UI interface, so edit31 is null.
Solution: edit31 = (EditText) findViewById (R. id. edit31); the location is adjusted to setOnClickListener (); The above is removed, and the bug is fixed. For example:
3. BUG (sqlite related)
Encountered: unrecognized token .... An SQL statement returns an error address: db. update ("thing", cv, "thing_name =" + name, null); // name is the String type of the passed parameter.
Study: SQL statements have problems. name is of the character type, and '''single quotation marks should be added to SQL statements.
Solution: 1. String [] str = {name };Db. update ("thing", cv, "thing_name =? ", Str );
2Db. update ("thing", cv, "thing_name = '" + name + "'", null );
4. BUG (sqlite related)
Encountered: NotFoundException: String resource ID #0x4
Research finds out the cause: Toast. makeText (context, reslut. length, 5000). show ();//Reslut. length is int type,The String type is required in Toast. makeText ().
Solution: Convert int to String or + "" after the int value, for example:Toast. makeText (context, reslut. length + "", 5000). show ();
Continuous accumulation. If any error occurs, please kindly advise. Thank you.