I want to know how to open files in the app that are present in other apps.
Like Gmail, What's app use file sharing(Attach file) from Gallery and File Manager.
(Could you Suggest a elegant way to do this)
Related
Since methods like getExternalStorageDirectory() , getExternalStoragePublic() are deprecated so how can i access the files of folders like DCIM , DOWNLOADS without letting user to choose or interact like any gallery app opens all images available on device or like any file manager app shows files of Directories . How can i achieve that ?
MediaStore is the new and best practice for any storage related stuff.
https://developer.android.com/reference/android/provider/MediaStore
I have an android app which allows the user to gather research data. I want to export the gathered data as an excel file. So the user can work with the data on a desktop computer.
The question is, what is the best way in terms of usability to offer file export to the user?
On idea was to start the email client with the excel file as attachment. But if you have to send this email to yourself just to get the files seem kind of a workaround.
The second idea is to store the file in the android file system. But is there a commen folder for something like that? Like the "Documents" folder in windows? I dont want the user to search too long for his file. And is this really best practice?
The common way, is using the shared intent system and allowing the user to pick which app "he" or "she" wants to use to share the file. You can also save it to the android file system just as easily. There is no common folder which everyone should use. But if you want ease of accessibility for the file, create a new sub-directory under the top-level directory on the device. Use this method to get a reference to the top-level, Environment.getExternalStorageDirectory(). You must have the android.permission.WRITE_EXTERNAL_STORAGE permission declared in your app Manifest. The sub-directory name should be something obvious to that user that the data inside belongs to your app. Furthermore, display a toast that indicates to the user where the file is stored to make it even easier for them.
As part of an app I'm writing, I need an ability to look for specific files, like .doc or .rtf, from within the app. After finding them, the app will store their adress or something like that, so that they could later be opened when necessary. The app wouldn't open them itself, it will use a different app for that. So, all I'm looking for is a way to browse for those files from within my app.
As i understand you need to find files with given extension. For this approach you can use FileFilter. Check this answer.
The file is somewhere in the data/data/appfolder/sharedprefs/ folders but these files seem to be hidden to people that didnt make the app.
I want to upload the file to dropbox but i cant because like i said the file seems to be hidden to dropbox. How can i change the file permissions so that it is no longer hidden and i can upload it to dropbox?
My app will probably need root permissions which it has. I want to upload the file using dropboxs apis for back up and restore purposes. Normally i just point to the file path and it uploads it, but its giving me a file not found error with these files.
Thanks
It's not that it's hidden, it's that other apps do not have permission to access your app's files. This is a good thing! It means your app can be the gatekeeper that provides access to those files on an as-needed basis. You don't need or want root permissions in a well-behaved app.
The correct way to provide a file to another app for use in things like ACTION_SEND intent URIs is to write a simple ContentProvider. If you're just providing simple read-only access to a file and you don't need the ContentProvider to be queryable, this is a lot easier than it sounds.
The two ContentProvider methods you'll want to implement are getType and openFile. In openFile you can enforce access restrictions however you would like for your app, and then return a ParcelFileDescriptor to the file.
On Android I understand an app can ingest an image file from the user's Downloads folder, and then use that image to direct content inside the app. Amazon MP3 Cloud Player is good example.
I understand that on iOS the Saved Photos folder can be accessed by apps as well, using the UIImagePickerController Class Reference. I understand that I can limit which media assets can be browsed, just video or just photos, but can I tell the app to only launch the media asset picker for the user ONLY if an exact-match to photo file extension is made in the first-place?
In other words: IF in the Saved Photos folder there is a .ONE or a .TWO file present, then launch the media browser, and only show .ONE or .TWO files, if not, do not launch the media browser.
I want to be able to use a custom file extension -not the standard PNG, JPG, etc...
Ultimately my goal is to use this custom image file as a kind of token that tells the app the user has done something in the browser to acquire the image file, and therefore is entitled to a special experience in the app.
What you want is not a UIImagePicker, because you need to enumerate user photos programmatically. Have a look at ALAssetsLibrary, with which you can enumerate ALAssets, which are proxy objects for saved photos (and videos).
Upon further reading: I don't think your custom extension idea would work. And it shouldn't, because you're exposing implementation details to the user by putting certain specialized files into a content library where they don't belong (which probably won't work). Do not misuse OS facilities like that. It will only get your app rejected from the app store (if it even works), create more headaches in implementation, and create very poor user experience. While this might not be enforced on Android, it is a bad idea even there, but on iOS, you won't even be able to release your app to the public.
See this question for how to declare your app to open specific document types (which means that when the user downloads a .yourSpecialFileType file in Safari, it will launch your app and hand the file over to you).