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.