How to securely store application files within its package folder structure? - android

My question is pretty general; whenever an android app accesses internal storage environment path; its folder structure is created into device's "Android->Data->app_pakage".
Image files within this folder won't be viewed from gallery; which is fine.
There are lots of app which secures this files (Can't be opened directly from file manager);
Examples for this are music apps; they provide encoding of its downloaded files, so it can be accessed only from that app only. This encoding changes its extension
So my question is here, How this can be achieved?. I am looking for simplest solution, which don't require a high, complex encryption algorithms.
In-Short, I want to prevent users to access app files from file manager- internal storage

Please have a look at this link
https://developer.android.com/training/data-storage/files.html
Here there is detailed explanation.
To have files that can only be accessed from your app please use -
getFilesDir()
Returns a File representing an internal directory for your app.
Files saved here are accessible by only your app.

Related

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.

Download Audio file like Gaana Android app

I have created an Android Application, in that I am playing and downloading audio file from server. So when user download audio file from server he/she can't show that file in File Manager or any other media player like Gaana app.
How to make it possible?
Thanks,
Sagar.
You can save the files in Internal Storage Area. These files would be private to your app only.
Using getFilesDir() on any context provides absolute path to the filesystem directory where your internal files are saved. There in you can create directory. For more information refer here
You can use few approaches:
Download files into the private application's directory. No other apps will have access to those files. Pros of this approach is that is is the easiest way. Cons is that the inner storage might be limited in the device.
Download files saving them with incorrect file extensions. Pros: easy to implement, can save anywhere. Cons: files can be accessed, copied and renamed by any other app.
The same way as 2nd approach, but add some encryption to the files, so nobody except you can use them. This approach might require on-the-fly decryption.

Hide images in compiled apk

I have a list of images referenced from the res/drawable folder. I realized that these images can be viewed from the compiled apk file when the file is opened with a file compressor program such as winrar. Is there a way to hide my images so that they can't be so easily accessed by snooping users?
The best option I see here is not saving your images inside the app. Instead, save them on your app server and get each image only when it's needed.
If your app don't have a server, you can save the images obfuscated inside your app (for example: base64 encoded or encrypted with a hard coded key). It won't stop a hacker but it will defend you from the common user.
From your comments it sounds like you want to use Internal Storage.
From the above link:
You can save files directly on the device's internal storage. By
default, files saved to the internal storage are private to your
application and other applications cannot access them (nor can the
user). When the user uninstalls your application, these files are
removed.
Just google or search stackoverflow on how to use Internal Storage if you need more help outside the Android docs.

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.

Android Add/Remove File Directory

I'm creating an App where I will import files the app will use, then remove and replace them with new ones when available. What folder should those be stored in?
The Android dev documentation have a page about how to handle files: http://developer.android.com/training/basics/data-storage/files.html
Maybe you should take a look at that.
It depends on how the user will get the files for the app, and the type of files you are talking about.
If for example the app is going to download the files from a server for the user, and the files are of a type that are only going to be used by your app, then either the Internal Private or External Private storage are probably best. If the file type is something that other apps will also use, then one of the appropriate External Public directories is best (for example Music, Pictures, Movies, Downloads etc).

Categories

Resources