I am creating an app having a large database file of 450 MB. I am storing it in SD card. I want to secure it as it has some sensitive data. If anyone can tell me the best way to do it, it will solve my problem.
I also tried a sample but it was working for small DB file. If I am using 450 MB Db, it is not working and it takes a very long time.
And also please let me know whether it is possible or not to secure such a large data.
It kind of is, but not really. You can encrypt it, and get the decryption key from a server. There is no other way to secure it, as the user can always pop the sd card into an sd card reader. And if the decryption key is local they can decompile your app.
Here's the problem- the encrypted file can't be used by SQLite. So you'd have to decrypt it to disk, and it can be grabbed at that point. So no, its not really possible to secure a database file at all. You're better off keeping the information on a server and querying it via webservice if you want to keep the data secret.
Related
I haven't been able to find a clear answer to this question, so here it is;
I want to use Realm for Android to store files in an encrypted way, then be able to open/view those files without needing to actually save them in the phone. Those would be sensitive data file so It would be perfect if it stay in the local database of my app.
Is Realm well suited for my case or if not, what else would be for Android?
Realm suits or not. You may need to reconsider.
If you just want to encrypt a database, it is easy. Just give it an encryption key when you init a Realm instance.
However, there are some side effects.
Save big files to Realm will slow it down.
The danger of data corruption. If you database file is corrupted, all data is lost. So you have to backup. That means saving files into Realm will cause your app takes at least twice the size of saving the files in filesystem directly.
The encryption key. You must design an encryption key that basing on each device other than just using one same key in your app. Or someone just needs to copy the database file from another's phone to his own and your app will decrypt the database for him.
You can check out this previous answer for a more deep explanation about saving images on Realm (it's on iOS, but the basics are the same: Don't do it if there's a lot of images.)
In your specific use case, did you consider saving encrypted images on the filesystem and the references for the image in Realm? You just need the file path and the encryption key in the database to work.
I'm working on an application that it took me about 2 whole month to collect data.
how can I protect my database and files? because of a big size of database, I zipped it (with password) and put it in asset folder. I can unzip it.
2 questions:
where I can extract it that no one can access it even though they have a rooted device ?
after extracting my database from zipfile ,I want to copy it to my application database . is there anyway users can access the database ?
Depends on how smart an attacker you're expecting. If you're expecting the average user, don't worry about it- just put it in your data directory, they'd have to root the phone to see it. From a power user you can encrypt the files. From a determined hacker that won't work- he'll decompile the apk and find the key. You can pass the key from a website, but a good hacker will run it under a debugger and find the key in memory. The best way to secure most of the data would be not to have it in the app but only download what you need via webservice as you need it, but that will cost money and time.
As I know there is no way to hide your files from user sight. they can access your resources sometimes so easy. but you should encrypt your data.
You can use SQLCipher library to protect your data. see http://sqlcipher.net/
Although it has some overhead but you can distribute your data in a safe way.
Hope it can help you
I do have an android application that downloads PDF files for display in a magazine app.
To secure the data I am already setting a user password. I was additionally thinking of removing the last 100 bytes of each file when stored on the device and adding them during run-time.
This at least would render the PDF not readable anymore.
Does anyone have a suggestion on how to achieve this with moderate effort and at the same time keeping the calulcating overhead low?
Thanks for any advice here.
encryption seems to be the best approach for you.
https://developer.android.com/reference/javax/crypto/package-summary.html
How to encrypt and decrypt file in Android?
Team,
I have an Android application with large SQLite database this data costs me lots of money and I don't want to let anybody have it easily.
This database come to me as databse.sqlite file and I shipped into into the APK assets.
is there anyway to encrypt this database before shipping and then decrypt while reading the data ?
P.S I searched for this a lot and all of my results point me to use sqlcipher but this lib does not work with shipped SQLite database file.
The problem is that you will need to store the key (or location of the key) somewhere in your code and deodexing the application doesn't take that much effort. Unfortunately, you can't really prevent anyone from accessing the data. You can only make it harder, but it will still be pretty easy for someon who is really determined.
The best solution would be to store the database on a server and only send the data the user actually needs to the device. That way you have at least some control over what data a device requests.
I have a library app where I store different books as sqlite dbs. The number of books can go on increasing and this gives SqliteFullException when internal storage is used. If I use external storage then is there a way that the user won't be able to access these files? Also, what is the best way to save such large number of databases without exposing them to users?
tough call. currently there is no protection in sdcard.
the internal memory is limited.
if your db file is limited in size <10 mb you can encrypt them and put it in the sdcard, and decrypt it when you want. the size limit is for the decryption time. larger files take longer to decrypt.
currently only security through obscurity is possible.
EDIT
as for your large you can have one db per book.
I would suggest creating a webservice where you store all your data and let the client(phone) request the needed info from the webservice. You can protect your data by building authentication functionality into your webservice.