Small cursor null, count and close()
This commit is contained in:
parent
0506160f7b
commit
05aa6a39fa
@ -493,8 +493,11 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
AppProvider.getCanUpdateUri(),
|
||||
AppProvider.DataColumns.ALL,
|
||||
null, null, null);
|
||||
if (cursor.getCount() > 0) {
|
||||
showAppUpdatesNotification(cursor);
|
||||
if (cursor != null) {
|
||||
if (cursor.getCount() > 0) {
|
||||
showAppUpdatesNotification(cursor);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
cursor.moveToFirst();
|
||||
count = cursor.getInt(0);
|
||||
if (cursor != null) {
|
||||
if (cursor.getCount() == 1) {
|
||||
cursor.moveToFirst();
|
||||
count = cursor.getInt(0);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
return count;
|
||||
|
@ -34,13 +34,15 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
final String[] projection = InstalledAppProvider.DataColumns.ALL;
|
||||
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
|
||||
if (cursor != null) {
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
cachedInfo.put(
|
||||
cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID)),
|
||||
cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE))
|
||||
);
|
||||
cursor.moveToNext();
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
cachedInfo.put(
|
||||
cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID)),
|
||||
cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE))
|
||||
);
|
||||
cursor.moveToNext();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user