1. cursor is not disabled when a large number of databases are queried.
Incorrect syntax:
Cursor cursor = getcontentresolver (). Query ();
If (cursor! = NULL)
{
Cursor. movetofirst ();
While (! Cursor. isafterlast ())
{
..............
}
}
Correct syntax:
Cursor cursor = getcontentresolver (). Query ();
If (cursor! = NULL)
{
Cursor. movetofirst ();
While (! Cursor. isafterlast ())
{
..............
}
Cursor. close;
Cursor = NULL;
}
2. Bitmap objects are not recycled in time
Because bitmap objects occupy memory, it is best to use bitmap. recyle () to reclaim the memory occupied by bitmap objects after the bitmap objects are used up.
3. convertview in the cache is not used in the adapter
Incorrect syntax:
Pubic view getview (INT position, view convertview, viewgroup parent)
{
Layoutinflater Inflater = (layoutinflater) Context. getsystemservice (context. layout_inflater_service );
View view = Inflater. Inflate (R. layout. listview_item_manage_bookshelves, null );
........................
}
Correct syntax:
Pubic view getview (INT position, view convertview, viewgroup parent)
{
View view;
If (convertview = NULL)
{
Layoutinflater Inflater = (layoutinflater) Context. getsystemservice (context. layout_inflater_service );
View = Inflater. Inflate (R. layout. listview_item_manage_bookshelves, null );
}
Else
View = convertview;
........................
}
4. Reclaim resources based on the activity Lifecycle
In the onstop () or ondestroy () method, some methods and objects are recycled, for example:
If (marrarylist! = NULL)
Marraylist = NULL;
......................
.......................
System. GC ();
System. GC ();