Use managedQuery to let Search Activity automatically dispose of it's Cursor.

Should be somehow done via Loaders someday.
This commit is contained in:
AlexanderR 2014-04-05 10:32:58 +11:00
parent 793bd618ac
commit c1daa99617

View File

@ -47,6 +47,7 @@ public class SearchResults extends ListActivity {
private static final int SEARCH = Menu.FIRST;
private Cursor cursor;
private AppListAdapter adapter;
protected String getQuery() {
@ -107,10 +108,12 @@ public class SearchResults extends ListActivity {
if (query == null || query.length() == 0)
finish();
Cursor cursor = getContentResolver().query(
if (cursor != null) cursor.close();
cursor = managedQuery(
AppProvider.getSearchUri(query), AppListFragment.APP_PROJECTION,
null, null, AppListFragment.APP_SORT);
TextView tv = (TextView) findViewById(R.id.description);
String headertext;
int count = cursor != null ? cursor.getCount() : 0;