当前位置: 动力学知识库 > 问答 > 编程问答 >

Android: how to query for the document files in android

问题描述:

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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: