Private sd storage - android

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.

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.

Android: Save a file to external memory

I have some audio files that my app is downloading, and due to the size of the files it would be nice if I could store them on the user's external storage. However I need them to remain private to my application. Is there any way to accomplish this?
Not literally.
You could encrypt them, but then you would have to handle the playing yourself, in order to decrypt them (or play some game like streaming them from a local "server" which decrypts them as it reads).
Realize also that even things within your .apk itself are accessible on most devices (you will need to use care in obfuscating the encryption key), and the contents of your app's private storage folder are readable on the multitude of rooted devices.
One simple suggestion would be to encrypt your file and then store it in external memory. This would keep the data safe and secured. Other application wont be able to access it. To accomplish this you need to convert the file into ByteStream. Then using encryption function encrypt it and store to external memory. Change the extension of your file to some user-defined extension like myExt and store all in certain folder. When you want to use those files in your application, decrypt it and use it. The encryption key will help you to securely protect data.
As per my knowledge this will prevent other application to access your information.

Backup SharedPreferences in Android to local Server or Device

I am developing an App for a lot of Devices, so that they aren't registered to a Google Account.
But I want to backup my SharedPreferences somewhere. In best case in a folder on the device.
So I tried to use the BackupAgentHelper, but this backups only to Google or can it backup somewhere else ?
Alternatively is there a way to copy the SharedPreferences to a place on the sdcard?
The problem is when I doing a update to my app (not trough the market) I lose all my data.
PS: Sorry for my bad englisch
Using BackupAgentHelper only uses the in-built Google backup system, and won't do anything useful for you if you don't have a Google Account on the device.
SharedPreferences files are just regular files in your app's data directory. If you want to copy them to the SD card, or your own server, on command, you can do that using the normal File API. It sounds like for what you're trying to achieve, it might be easiest to just call Context.fileList() to get an array of files in your apps' internal storage, and then iterate over that array, copying each file to a folder on the SD card.

Save files to device only my application can see

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.

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