I have been trying to integrate google drive sdk in my android application. It all seems to work fine but now i have a requirement where in i would like to list out all the files with the same extension. For example I would like to get a list of all JPG files that the user might have saved to his google drive.
For doing this i tried to use the following
FileList temp = service.files().list().setQ("title contains 'jpg'").execute();
But this does not return me anything.
On the other hand if i replace jpg with one of the words in the file name then it seems to work fine. So strangely a search on extension is not working while a search on the main name seems to work
Is this functionality broken with the drive sdk or am i missing something here?
Google Drive determines file types based on their mimeType attribute, not their extension. Instead of looking at the file name, try something like:
FileList temp = service.files().list().setQ("mimeType = 'image/jpeg'").execute();
From the comment left by Burcu Dogan it is clear that at this point of time querying based on file extensions is not possible. Will have to wait for an update to the google drive sdk to include such functionality.
Putting this out as a note to help anyone who might be facing a simialr issue and looking for a solution.
Related
My Flutter (Android and iOS) app generates KML or GPX files, which works as expected.
Now I want to add a button "Open file" which should open such a system dialog where the installed map or other consuming apps (which can handle such formats) are listed to be chosen.
How can I open this dialog? How can I find the format-related apps and how can I send the file to these apps. I guess, there is a plugin for this, but couldn't find one. It must work on Android and iOS, nice-to have is web support.
I just saw open_file but I am not quite sure, if it works as expected because it doesn't list support for KML/GPX.
Thanks in advance!
If you found a Flutter plug-in that is open source like open_file, you could just add in the MIME types yourself.
For KML format: https://en.wikipedia.org/wiki/Keyhole_Markup_Language
For GPX format: https://en.wikipedia.org/wiki/GPS_Exchange_Format
As the package is open source I was thinking of modifying the code, as the mapping appears to be straight forward:
https://github.com/crazecoder/open_file/blob/master/ios/Classes/OpenFilePlugin.m
and
https://github.com/crazecoder/open_file/blob/master/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java
You would need to fork the projects and add in the types you wanted.
Alternately you've posted issue ticket #116
where the repo owner responded with
OpenFile.open("/sdcard/example.txt", type: "text/plain", uti: "public.plain-text");
Do respond if that works, as I was uncertain if both of the different platforms' filetype (uti vs MIME type) works universally in Flutter or if you have platform specific detection code to assign the filetype correctly.
I created an little application in Xamarin.Forms to get the images in my file with XLabs. It work with android and IOS.
But now, i want to import file and i search the best plugin to do that.
I found this : https://developer.xamarin.com/recipes/android/data/files/browse_files/
But it dosent exist with IOS. And i don't know if it's possible (to search and get file)
And it's why i come here, to get answers.
Can you give me a plugin or a solution to get file/path of any file with OpenDialog, intent, or page custom
Thank you
Are you wanting something that can search files outside of your app's directory on iOS or only files within the app's directory?
If you want the former, iOS severely restricts this kind of thing, unlike Android. So it is not possible to do the same thing on iOS that you can do on Android.
Look at the second paragraph here and see that the app is sandboxed which means it cannot view files outside of it's own directories.
That being said other apps can make files available to be shared with other applications, see here.
You can also get access to other files from the device's iCloud account. See this for pre-iOS 8 and this for post iOS 8.
I have an android app that reads spreadsheets from google drive and shows it to the user as a contact list. It is design to be a phone list you can send to your team members.
https://play.google.com/store/apps/details?id=com.ctw.cloudpeepsfree
Anyway, to get to work, all of the Google drive file names need to begin with prefix "peep:". I have heard rumors that with the latest versions of Google Drive API, I should be able to instead put all of my app files into a special folder that only my application can read. I was looking for some sample code or article on this subject. Thanks...
found this blog:
http://googleappsdeveloper.blogspot.com/2013/04/more-ways-for-apps-to-write-to-drive.html
You can use application data folder in your case, but use won't be able to list the file you put it on appdata folder: https://developers.google.com/drive/appdata
In order to put a file in the appdata folder, just set its parent to "appdata":
File body = new File();
body.setTitle(title);
body.setDescription(description);
body.setMimeType(mimeType);
body.setParents(Arrays.asList(new ParentReference().setId("appdata"));
service.files().insert(body).execute();
I have an application that will mail users attachments of text files. Receiving users can upload the file using this application. My question is
1) Is download folder the default location for downloading files?
2) Is it necessary for me to provide a folder exploring options before the files can be uploaded?
Any suggestions?
Jai
1)It depends on your actual call and how you are receiving the data / storing it. From what I've seen it will download to one static location however it's probably not a good idea to lean on that. There is always a possibility for that file to be moved by the user which could result in a crash or strange errors.
2)I would look into that or having the application create a temp folder to store the aforementioned text file in.
Good luck!
!k
I am new to Android and Eclipse development, but not new to software development in general.
As my first real project, to get over the learning curve, I am modifying the SDK example soft keyboard.
I would like to add a macro capability. So far so good.
I have created a Permissions file to hold the macro string definitions and store that in the getApplicationInfo().dataDir – which turns out to be something like "/data/data/…". I can write then read back a single key-value pair – so I know the file exists. But, I can't see the file using Astro file manager or an FTP program looking at the Device. I have a feeling I may not have the access permissions to view the directory and I don't have root.
I would have liked to edit the macro definitions in this file on a PC and then save it back to the proper location – that would've been the easy solution. I think my other options are to create a simple key-value parameter by parameter editor or somehow use intents to open the file using some already available text file editor. I am guessing the second option will also encounter the file permissions problem.
A third option would be to store the file in some publicly available directory. I tried using a few "get DIR's", but they required a higher level SDK than I was using – I would like to stay compatible with version 6 and below.
Can somebody offer suggestions on how I can edit the key-value pairs or find a public place to create this file? And, where to look to find an example of how to implement the suggestion?
Thanks much,
Barry.
You can save any data in the SD card. Please read the SDK here, where there is a code snippet which may help you.
Try saving the file on your SD card.
http://androidgps.blogspot.com/2008/09/writing-to-sd-card-in-android.html