I query the video in my phone to display 0 pieces of data in the background
@ Override
public void initData() {
AsyncQueryHandler asyncQueryHandler=new AsyncQueryHandler(getActivity().getContentResolver()) {
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
Utils.printCursor(cursor);
}
};
int token = 0; // Message.what
Object cookie = null; // Message.obj
Uri uri = MediaStore.Video.Media.INTERNAL_CONTENT_URI;
String[] projection = { //
MediaStore.Video.Media._ID, MediaStore.Video.Media.TITLE,
MediaStore.Video.Media.DURATION, MediaStore.Video.Media.SIZE, MediaStore.Video.Media.DATA,
};
String selection = null; //
String[] selectionArgs = null; //
String orderBy = MediaStore.Video.Media.TITLE + " ASC"; //
asyncQueryHandler.startQuery(token, cookie, uri, projection, selection, selectionArgs, orderBy);
}
Utils
/**![][1]
* Cursor
* @param cursor
*/
public static void printCursor(Cursor cursor) {
if (cursor == null) {
return ;
}
Logger.i(Utils.class, "" + cursor.getCount() + "");
//
while (cursor.moveToNext()) {
//
Logger.i(Utils.class, "---------------------");
for (int i = 0; i < cursor.getColumnCount(); iPP) {
String columnName = cursor.getColumnName(i);
String value = cursor.getString(i);
Logger.i(Utils.class, columnName + "=" + value);
}
}
}