Skip to content

Instantly share code, notes, and snippets.

@wangmuy
Last active August 30, 2016 09:41
Show Gist options
  • Save wangmuy/a63dc8ee239048f24081 to your computer and use it in GitHub Desktop.
Save wangmuy/a63dc8ee239048f24081 to your computer and use it in GitHub Desktop.
android.provider.Cursor Iterate
void iterate(Context context, Uri uri) {
Cursor c = null;
try {
final ContentResolver resolver = context.getContentResolver();
final String[] prjection = { BaseColumns._ID, PKG_NAME };
c = resolver.query(uri, prjection, null, null, null);
final int pkgColumnId = 0;
while(c.moveToNext()) {
String pkgName = c.getString(imColumn);
// TODO: do something
}
} finally {
if(c != null)
c.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment