What is the correct MIME type for json file(json extnesion) so that only see json files show up when I am browsing the file system through intent?
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/json");
Intent i = Intent.createChooser(intent, "View Default File Manager");
startActivityForResult(i, 1);
thanks
Surprisingly, Android does NOT support "json" (and "js" for javascript extension) as a MIME type. This is clear, for example, from the source codes of MimeUtils. Also you can use MimeTypeMap
helper class and find out that:
MimeTypeMap.getSingleton().getMimeTypeFromExtension("json");
returns null
;
The only most close MIME type that can be used instead of "application/json" is "application/octet-stream": it matches "*.json" files among other things, but a lot of other stuff as well. At least it filters out images, texts, music files and videos.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With