【发布时间】:2016-11-28 04:46:35
【问题描述】:
我想获取除视频、图像和音频文件之外的所有类型的文档 pdf、xml、doc。
并显示带有名称、大小、日期和位置的列表。
ContentResolver cr = context.getContentResolver();
Uri uri = MediaStore.Files.getContentUri("external");
// every column, although that is huge waste, you probably need
// BaseColumns.DATA (the path) only.
String[] projection = null;
// exclude media files, they would be here also.
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="
+ MediaStore.Files.FileColumns.MEDIA_TYPE_NONE;
String[] selectionArgs = null; // there is no ? in selection so null here
String sortOrder = null; // unordered
Cursor allNonMediaFiles = cr.query(uri, projection, selection, selectionArgs, sortOrder);
我正在使用此代码从移动设备获取文档,它有效吗?以及如何获取 uri、日期和名称等文档详细信息。提前谢谢。
【问题讨论】:
-
我编辑了我的问题,请检查 -- @gnat