在query列表时全部查询再把cursor传递出去
使用cursor.getxxx()
就可以了
Uri dirUri=UriUtil.pathToUri2(path);
Uri childrenUri= DocumentsContract.buildChildDocumentsUriUsingTree(dirUri, DocumentsContract.getDocumentId(dirUri));
String[] proj= new String[] {
DocumentsContract.Document.COLUMN_DOCUMENT_ID,
DocumentsContract.Document.COLUMN_DISPLAY_NAME,//文件名
DocumentsContract.Document.COLUMN_MIME_TYPE,
DocumentsContract.Document.COLUMN_LAST_MODIFIED,//最后修改时间
DocumentsContract.Document.COLUMN_SIZE//文件大小
};
Cursor cursor= context.getContentResolver().query(childrenUri, proj, null, null, null);
if (cursor == null){
return null;
}
while (cursor.moveToNext()) {
Uri uri = DocumentsContract.buildDocumentUriUsingTree(dirUri, cursor.getString(0));
String name=cursor.getString(1);
boolean isDir=cursor.getString(2).equals(DocumentsContract.Document.MIME_TYPE_DIR);
boolean isHidden=name.startsWith(".");
}
cursor.close();
网友评论