9
votes

I am struggling with how to make a custom file extension open in my android application through the google drive ui. My file currently opens fine through dropbox or the android file explorer. Google drive seems to only consider the mime type of the file. The file extension is my own (lets say .xyz) and the file is xml on the inside. I want the file to open in my app not just any app registered to open text/xml mime types. How can i tell google drive the .xyz files are not to be treated like text/xml. Similarly i don't want my app to be registered to open all text/xml files.

So the end user workflow would be this: 1) Open Google Drive android app. 2) Tap "somefile.xyz" -> The file would be opened in my app. Currently it opens in the google drive xml viewer. 3) Tap "otherfile.xml" -> The file would not be opened in my app.

2

2 Answers

1
votes

Turns out the answer to this question is you can't do that.

With a file called .xyz and a format of xml on the inside the best you can do is to create various intent filters to handle all the ways other apps identify the file. For Example I put the following mimeTypes in my intent filters.

  • Google Drive - text/xml
  • ICS Gmail - text/plain
  • JellyBean Gmail - application/octet-stream
0
votes

You can save your files to the private directory of your application then it will not be accessed by any other app

See through this link how to do that

http://developer.android.com/training/basics/data-storage/files.html

Context.MODE_PRIVATE and getFilesDir() can be helpful to you.

Or if you want other apps to do something for you and return the result to your application Go through with this.

http://developer.android.com/training/basics/intents/sending.html

or

http://developer.android.com/training/basics/intents/filters.html