Last active
August 30, 2016 09:41
-
-
Save wangmuy/a63dc8ee239048f24081 to your computer and use it in GitHub Desktop.
android.provider.Cursor Iterate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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