Small cursor null, count and close()

This commit is contained in:
Daniel Martí 2015-04-01 17:04:51 +02:00
parent 0506160f7b
commit 05aa6a39fa
3 changed files with 19 additions and 12 deletions

View File

@ -493,9 +493,12 @@ public class UpdateService extends IntentService implements ProgressListener {
AppProvider.getCanUpdateUri(),
AppProvider.DataColumns.ALL,
null, null, null);
if (cursor != null) {
if (cursor.getCount() > 0) {
showAppUpdatesNotification(cursor);
}
cursor.close();
}
}
private PendingIntent createNotificationIntent() {

View File

@ -24,9 +24,11 @@ public class AppProvider extends FDroidProvider {
final String[] projection = { AppProvider.DataColumns._COUNT };
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
int count = 0;
if (cursor != null && cursor.getCount() == 1) {
if (cursor != null) {
if (cursor.getCount() == 1) {
cursor.moveToFirst();
count = cursor.getInt(0);
}
cursor.close();
}
return count;

View File

@ -34,6 +34,7 @@ public class InstalledAppProvider extends FDroidProvider {
final String[] projection = InstalledAppProvider.DataColumns.ALL;
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
if (cursor != null) {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
cachedInfo.put(
@ -42,6 +43,7 @@ public class InstalledAppProvider extends FDroidProvider {
);
cursor.moveToNext();
}
}
cursor.close();
}