Android development error points

Source: Internet
Author: User

For Android programmers, we need to pay attention to the development of Android applications in many aspects. The following section describes how Android123 is easy to browse most of the source code.

I,Database Cursor

For the returned object Cursor of the Android SQLite database encapsulation query, errors may occur.

1. Cursor may return null.

If the Cursor object returned by the query is null, any method to execute the cursor must have a null pointer. This Android code 40% has not noticed.

2. Cursor returns 0.

We can only judge whether it is null or not. If the Cursor object is 0, we will execute moveToFirst (). This method will be embarrassing. This is a prompt for attention outside the Android development grid.

3. When traversing Cursor, no moveToFirst () is executed, so that the Cursor position is uncertain.

4. manually close Cursor after use. Do not forget the cursor. close () method.

5. Obtain the Cursor type, such as getInt and getLong. Since the boolean and long types in SQLite are all SQLite integers, remember to convert them during reading.

II,The newly created service and activity are not in androidmanifest. register in xml. For activity, if the package name used by the service is different from the package name of the main program at the same time, remember to manually write the relative package name

III,When Parcelable is used, internal class Exception Handling occurs. For example, if the Bitmap object is empty when the Bitmap object is stored internally, the problem may occur.

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.