Search json file using intent
What is the correct MIME type for the json file (json extnesion) so that only the json file view appears when I view the file system using 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);
thank
source to share
Surprisingly, Android does NOT support "json" (and "js" for the javascript extension) as a MIME type. This is understandable, for example, from the MimeUtils source codes . Also you can use a MimeTypeMap
helper class and find out that:
MimeTypeMap.getSingleton().getMimeTypeFromExtension("json");
returns null
;
The only closest MIME type that can be used in place of "application / json" is "application / octet-stream": it matches "* .json" files, among other things, but many other things as well. At the very least, it filters out images, texts, music files and videos.
source to share