Android and android

Source: Internet
Author: User

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.

 

Related Article

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.