Save files to device only my application can see - android

I need to save files to local folder in my device.
This folder should be encrypted or shouldn't be seen.
Is it possible to do something like that in Android?
I know I can use shared preference or SQLite DB, but I need to save files not simple values.

You can save files to the internal storage of the device, which will be private to your application. Remember this storage is limited on most devices, and thats why the SD Card is the best place to store files.
Internal Storage
You could hash the files on the SD Card though, and only your application could access them because it has the key used to hash the files.

Related

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.

Saving a file to your own android application

When My application is running I want to capture some information and save this to a folder in my application rather than to the device. I have read online that it is not possible to save a file to your assets or res directory. However would it be possible to save it to another file in your application?I had a look at Shared Preferences but that seems to be only for Key Value pairs.
http://developer.android.com/guide/topics/data/data-storage.html
Writing to internal storage with MODE_PRIVATE should handle what I think you want..
You cannot store the files in the Assets or the Raw folder at run time.
Instead if you have image/video/audio/textual files you can store the files in your SD card and store the path of those files in your file in Database or shared preferences.
After installation each application creates a storage located in '/data/data/com.your.app.package.name'. Save whatever you want in that place.

Private sd storage

I have an app which takes pictures and saves them to sd, problem is that picture modification (delete,rename,ecc.) should be done just throught the app so I need a way to make the pictures folder not accessible to user...is it possible?
The only way is to encrypt the files that you store. There is no way to prevent users mount the sdcard to access every file stored in it.
In the common Android architecture the SD-Card is formatted using FAT32 filesystem. As FAT32 does not support any access control mechanisms you can not rely on that.
Therefore the only possibility is encryption. Create an encryption key and store in the private app data folder. Then use it for encrypting the privacy sensitive files you want to store on the SD-card.

Is it possible to create shared preference files in sdcard

Can anyone help me ? Is it possible to create shared preference files in sdcard rather than on private path of an android application.
You cannot modify where shared preferences are stored.Its a private storage. if you want to use sd card use
Environment.getExternalStorageDirectory(). and get the path of directories stored in sdcard.
it is possible by reading&writing the xml file into the external storage ,but it's not the same as sharedPreferences. you will have to implement your own way , or use the android code of this class.
however , there are some disadvantage over using the internal storage:
anything you store on the sdcard is visible to every application and the end user can read it by just opening it.
only in the internal storage you get some sort of protection against reading the file , so that only rooted devices can read the files.
external storage can also be unmounted , so the data can sometimes be unreachable. you need to handle possible errors that can occur because of this.
uninstalling the app while the sd card is mounted means that the data will stay on the sdcard .

Files internal to applications

I read this sentence, form a book
"Files: Files internal to applications, which you can store on a
removable storage medium"
and I am confused, well I expect that "Files internal to applications" saved from my app that will be accessible only from my app. and that is true when you save them internally in the phone memory.
But as the sentence says , you can save files to the sdcard also. And that is great but I think that everyone with 'external storage read' privilege set in the manifest will be able to read your file, so that doesn't make it internal to the app, it makes it publicly available to everyone.
My question is:
Is there any way to store the files in the 'removable storage medium' -> sdcard and those files to stay available only to my app, others application to be prevented from reading the content ?
I know that if you put files in data/data//files these files are only available to the app with that package name
It is possible . For that you need to encrypt the data with some private key and write to SDCARD, when ever you want to process that data you have to decrypt it . So another app can't access your data without decrypt it.
Android Encryption Example.
store the files in the 'removable storage medium' -> sdcard and those files to stay available only to my app
I don't think so, For sdcard it is not possible.
The one way is store encrypted file in sdcard and key for it is you can put (keep) in your application's shared preference in private mode and decrypt the file from your application when you want to read it. But I think it some ugly way.

Categories

Resources