XxGoliathusxX XxGoliathusxX - 1 year ago 119
Java Question

Android select and open file with custom extension

Which mimetype is necessary to give the user the opportunity to select a custom file (here: .oli) via the filebrowser? I already created one for xml. What do I have to change?

Intent chooseFileXML = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(new Helper(FunctionsActivity.this).getPathToAppFolder());
chooseFileXML.setDataAndType(uri, "text/xml");
Intent intentXML = Intent.createChooser(chooseFileXML, getString(R.string.importXMLDatei));
startActivityForResult(intentXML, REQUEST_CODE_IMPORT_XML_FILE);

Answer Source

Change text/xml to */*.

BTW, note that ACTION_GET_CONTENT does not take a Uri, so do not expect apps to pay any attention to that Uri.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download