Search code examples
androidgoogle-drive-apimime-typesgoogle-drive-android-api

Android Google Drive API how to set non-MIME file format


I have some file on my device, which I want to upload (and later download) to Google Drive. When creating a file on Drive, I have to set it's MIME type:

MetadataChangeSet.setMimeType("text/xml");

So, we have some specific MIME types, which allows us to upload different files.

But what I have to do if my file formats are not in this MIME-list? How can I upload/download files with formats like .style, .map, etc.?


Solution

  • Actually, I've found a solution.

    You can specify your own MIME type like this (for example .style):

    String mimeType = MimeTypeMap.getSingleton().getExtensionFromMimeType("style"); 
    

    It worked for me, at least.