Android Storage Access FrameWork and hidden files - android

Im new to Storage Access FrameWork on Android.
I need to be able to access hidden files on an external USB drive plugged into Android using the Storage Access FrameWork.
Im wondering if its possible for an app to access hidden files stored on an external USB drive connected to Android.
It seems in order to access a file, Android must display a dialog box where the user picks a file, giving the app access to only that file.
So if the file is hidden, it will not get displayed in the list of file presented by android to the user, so then the user cant pick the file, then the app wont have permission to access that file.
Is this correct? Is there a way around it?
Thanks

If you are familiar with Storage Access Framework then you I assume you are using Intent#ACTION_OPEN_DOCUMENT which launches the system documents picker.
Instead, use Intent.html#ACTION_OPEN_DOCUMENT_TREE. Then you will receive a DocumentFile that represents the directory and you can use DocumentFile#listFiles to iterate through all the files including 'hidden ones'.

Related

Access all files on android

I am trying to make a file manager type application and I want to access all files. I know it will need MANAGE_EXTERNAL_STORAGE permission but I am not able to figure out which api should I use.
I am trying to make a file manager type application and I want to access all files.
I'll recommend you to start from here : Manage all files on a storage device (keep in mind you cannot write internal storage on a non-rooted device).
I am not able to figure out which api should I use.
MediaStore might suit your needs (even if your question is a bit generic) , so give it a reading to Access media files from shared storage.

Access files of another App inside the Download folder - Android 10+

Trying to make some sense of this complete mess of scoped storage.
So I'm storing some files (logs) generated by App A inside the Download folder.
I'm using Mediastore/ContentResolver and no problems with that either for read or write access as long as it's from App A.
But then App B needs to read these files and here comes the problem.
Same way using Mediastore/ContentResolver but the files seem invisible for queries.
Download is supposed to be a Shared Storage, but files are indeed generated as -rw-rw--- which means no permission for others which could explaind why App B does not sees files from App A if they are not in the same group.
Would the Storage Access Framework method work around this?
Thi not tried it yet because poping system window's is definitely not something I wanted as a user experience for my App.
Thanks.
If the second app has 'all files access' with MANAGE_EXTERNAL_STORAGE it can also list the files of the first app.
Otherwise you can let the user of the second app pick those files with ACTION_OPEN_DOCUMENT of Storage Access Framework.
You better store your files in a sub directory as then second app can pick complete directory with ACTION_OPEN_DOCUMENT_TREE and list all the files.

Storage so my media/non media files are accessible by other apps

I am confused with the new app storage system in Android. I am not sure where my use case falls under and I need your help in telling me the right approach for this
My app captures images and generates pdf documents. Prior to Android 10, I used to store them in an app directory where the user can easily navigate to them through other files browsing app (like Files app on Samsung). In addition, these files can be accessed from within my app (so essentially read and write).
With the new storage, I am not sure how to accomplish the same thing. If I use the internal storage then user can't see them. If I use the media approach, well it seems it is only for Audio/video plus they will not be organized in a folder like I have them organized.
Am I missing something? How would I solve this problem?
Thank you
On an Android 11 device you can store your files in a subdirectory of the public Documents directory.
You can do that using classic File means or the media store or SAF.
Other apps can see them using SAF or the media store. Or with classic file means when requested all files access.
The user can see them using the default Files app on the device.

Only my application should have permission to access the files generated by app

My application generates some .csv files while running and these files are placed inside Android File system. These files are accessible outside the application also(as i can open these files in text editor and modify...)
Now I want that only my application should be able to read/write into these files.
Please help me in achieving this.
Thanks a lot.
These files are accessible outside the application also(as i can open these files in text editor and modify...)
Presumably that means you are placing them on external storage.
Now I want that only my application should be able to read/write into these files
Place the files on internal storage. This will prevent ordinary Android users from accessing the files except via your app.
Owners of rooted devices can get at those files, and if you are concerned about that scenario, then do not create any files at all, as owners of rooted devices can get to anything.
Also see article here: http://developer.android.com/training/basics/data-storage/files.html
It informs about internal vs external storage as well as making data public vs private for your app.

Accessing application data space

I am making a application wherein when I download the file through my application it gets downloaded inside my application data space. I am doing this basically because the files downloaded will not be accessed by users as they can access it if its stored in sdcard or internal memory.
So my question is that I want to open the file when user taps on the file by any third party application.ie. when the file is downloaded it will pop to open or not.If tapped on open then it should open by some other 3rd party application.
for e.g. if i download abc.doc then it should ask me to open through various readers.
Is this possible to do? and if not what solution can i implement?
Does this require the device to root..?
I am doing this basically because the files downloaded will not be accessed by users as they can access it if its stored in sdcard or internal memory.
First, "internal memory" is "application data space", assuming "application data space" refers to file storage and not RAM. There are only two places that you can write to in Android: internal storage and external storage.
Second, users who want to can access your file even on internal storage, such as by rooting their device.
So my question is that I want to open the file when user taps on the file by any third party application.ie. when the file is downloaded it will pop to open or not.If tapped on open then it should open by some other 3rd party application. for e.g. if i download abc.doc then it should ask me to open through various readers.
You could elect to make the file be MODE_WORLD_READABLE when you create it using openFileOutput(). This may allow some third-party applications to access the file. Or, you could implement a ContentProvider to serve this file. Either of these will also allow the user to access the file (e.g., via "share" options in those viewer apps), which runs counter to your original aim.
The only way you can have a file that is not accessible by users except through your app is if your app is the one to view (or otherwise work with) the file. And, as I noted above, even then rooted device owners can still elect to get to the file.

Categories

Resources