Android Storage access framework - android

I am writing a file encryption app.
I set up the file(s) browse code using the default storage directory.
This works great, I wrote the code to be able to encrypt multiple files as well as directories.
Directories simply get copied, and the files within are encrypted into a new directory.
The problem is now after some research I have found that I need to utilize the storage access framework to be able to select files from external sd cards, and any other storage system the user may have.
My question is, is there a way to select multiple files and folders simultaneously through activities in the saf? Is there a workaround for this? I found an activity that is able to select multiple files, and I found one that allowed me to select a single directory.

Related

Bundle app with files located in internal storage directory instead of assets directory?

I am building an app which will contain media files that are bundled with the application.
Users will also be able to download additional media files at runtime.
I want to store the downloaded files in the application's internal storage directory.
Is it possible to "bundle" the initial files in such a way that it is also stored in the internal storage directory, or will I need to place them in assets, and thus have two different ways of accessing my media files?
Is it possible to "bundle" the initial files in such a way that it is also stored in the internal storage directory
If you are looking to have them be placed there automatically, then no, there is no option for this.
will I need to place them in assets, and thus have two different ways of accessing my media files?
You are welcome to copy the assets to the filesystem yourself (see AssetManager). You would treat the filesystem as the "system of record" and only copy things there if needed (e.g., first run of the app, after user does "Clear Data").

How to restrict user from viewing/accessing the cached files from file explorer in an Android Device?

My requirement is to cache the files securely in android internal/external storage, where apps other than my app should not view/access the documents I store.
Current implementation:
Currently, the app uses context.getExternalCacheDir() as a base directory and followed by respective folder structure to cache files. The problem here is, any user can view the files stored by just navigating through the path using some File Explorer apps.
We can use context.getCacheDir() or file directory,
There are limitations in using it, as it has less space and the platform might automatically delete files when it wants space for other operations.
Required Implementation:
Encryption/decryption would be one way yet, please suggest other possible ways to cache the files securely, so that users cannot view/access using other external applications.
as it has less space
That is not true for most Android devices created in the last 8 years.
the platform might automatically delete files when it wants space for other operations
That also holds true for getExternalCacheDir().
please suggest other possible ways to cache the files securely, so that user cannot view/access using other external application
Use getFilesDir().

Where to put files for External Storage Android

So I have some files I want my Android App to access, read and write.
I want to store it internally. Where can I put these files in my Java Project so they are accessible or can this not be done?
There are three ways to achieve this, and according to your requirements select the approch
on SDCARD
This is the normal SDCARD/in-build SDCARD in newer smart phones. you need to create specific folder structure and put your files there, here you can do file read and write both
but this in insecure because accessible to all the application
on Internal Storage
This is given as Applicaiton specific storage where you can create the file and do the operation, this is most secure way to do it, but this is generated run time so you can not push the files directly, you can put your files in RAW or ASSETS and copy that here
RAW and ASSETS
This is in the code structure only and only read access is given to this folder, you can not change this file run time.
if you select any one of this approach then simple goggling will show you the sample code.
You can read or write files in the path of your internal storage as
data/data/package_name/files . I had already answered a similar question you can check it out.

How do android developers choose directories to store their files

I want to store some files when I develop an android app. There are two ways to store the files: use internal directory or use external directory.
As far as I am concerned, if the developers don't want their users or other apps can get access to the files, the file should be stored in internal directories. And if the developers do want the files can be accessed by users or other apps, the file would be stored in external directory.
And here is my question:
when choosing to store files in external directories, should I classify the types of files and store them in different directories like 'Download', 'Movies', 'Picture' ... or make a single directory for my app and store all my files in that directory.
As an android phone user, I don't like the second solution. So I am wondering why so many apps (such as Evernote) choose to create a directory in my external directory, '/sdcard'.
I would say if the files are of interest for the user or other applications store it in a type specific directory.
The second approach, one directory per app, can be used for files that are kind of private to the application. Many devices have more space available in external storage than in internal storage. An application may therefore choose to put its files there even if they are internal in nature.

How to provide some resource files for an android application?

I'm writing an android application, which user can download some image files from server. There image files will be stored in android mobile.
Now I want to put some of image files inside the apk file, that user can start the application quickly after installing. I found I can put them into assets directory, but the directory is read only. When user download other image files, I need to store them into another directory.
So there will be two directories to store the image files, but they are the same type.
Is there any good solution for this case?
Check out http://developer.android.com/guide/topics/data/data-storage.html#filesInternal for a listing of different places you can put data on Android.
You should put downloaded image files into one of three places, depending on your needs.
If the images are meant to be viewable by the user (e.g. downloaded photos), put them on the external storage. If they are meant to be user-interface elements or other crucial (but not user-facing) images, put them on internal storage. If they are meant to be cached for quick access but downloaded if necessary (e.g. temporary images like those found on a website), put them in the internal cache directory (Context.getCacheDir()).
If you don't have a lot of assets, you can copy them to the target location when your program first runs (e.g. check for the existence of a certain file, and create that file when you are done setting up). Then you only have to check one place (unless it's the cache dir, in which case you can't guarantee that the files will stick around forever).
If you have a lot of asset files, I would use a two-stage lookup: consult your downloaded image directory first (so you can override builtin assets, for example), then consult your assets directory. This is also flexible enough to allow you to make use of multiple storage locations should you find the need.

Categories

Resources