问题描述:

I am trying to list all the document files(.doc,.docx,.pdf,.xml,.java,etc) other than image, songs and video files.

String[] projection = { MediaStore.Files.FileColumns.DATA};

String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="

+ MediaStore.Files.FileColumns.MEDIA_TYPE_NONE;

Cursor cursor = context.getContentResolver().query(

MediaStore.Files.getContentUri("external"),

projection,

selection,

null,

null);

This is the query which i used. This query is returning too many files which contain images and other non readable files. Is there an efficient way to retrieve all the document files from android other than checking the file names for predefined extensions?

相关阅读:
Top