In my android application i need a file picker that only pick images and document.I have implemented that but it will pick other files like videos.I only need to pick documents like pdf,excel,txt,etc.. and images and all those under a file size of 5mb.Below is the code that i currently using.
final String[] ACCEPT_MIME_TYPES = {"application/*", "image/*", "text/*" };
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPT_MIME_TYPES);
//intent.setType("file/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"),FILE_SELECT_CODE);
} catch (Exception ex) {
System.out.println("browseClick :"+ex);//android.content.ActivityNotFoundException ex
}
I don't what i was doing wrong here that makes the selector to pick videos and othere files.Please help me to solve this.