I need to block user access to my app's data stored in the SD card... like the images etc as they are crucial to my app's proper functioning and if deleted by mistake, will cause the application to function way different from what is expected of it. Is there any way to do so programmatically, like when I create this directory structure during my first run, lock the access to it to be only unlocked when the app runs?
Short answer... NO, it's not possible at all.
If it's that important, you could store all your data in a encrypted file. That way if it's deleted then you know it's all deleted and you have to start again. You also know that it's 'most likely' haven't been tampered with.
Most likely tho, the best solution is to handle errors better and become a more robust application.
Related
I am making an application in android. Now the issue which I am facing here is, I want to save one id, which should persist even after uninstallation of app. So is there any way which may fulfill my purpose, and also will be a better idea ? And if yes, Please tell me about the solution.
Place your id in external storage like sdcard in a text file. This will then persist even after uninstallation of application. But the downside is that it is prone to user deletion.
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'd like to develop an app which need some data persistency. For some reason, I don't want to use database. And I'd like something similar to the shared preference. But only have one more requirement:
I hope my data can be persistent across installation. That means even the app uninstalled the data still be stored in Android system safely.
Are there any suggestions? Thanks
P.S.: In iOS, I use the keychain.It works perfectly.
The only solution I can think of to ensure non-removal on uninstallation is to write a file somewhere on the external storage. However this is (a) insecure (b) prone to other issues such as users deleting it.
If you are worried about persisting data on upgrades then using a database with a ContentProvider you can achieve this fairly easily. Shared Prefs are only really meant for a small number of small values/primitives.
There is also the option of storing something remotely, with a web service if it fits with whatever need you have to retain data when uninstalled/reinstalled.
The majority of questions like yours indicate an issue somewhere else in the way your application is architected, if you provide more detail people here may give you a better solution
The only way I can think of doing it is syncing the data with the cloud and restoring it if the user reinstalls the app. You may want to look at leveraging the BackupManager.
I would like to know if its possible to save an object at the moment the user is installing the app on mobile.
Why I want this?
My app uses some default objects to his normal behaviour, whenever the user starts the App I want that the objests are there to be used. I could certainly just create them each time the user opens the app..
But that might consume a bit of unnecessary time and performance and battery.. If its default, I want to create only once, and then its always there.
I will also use Internal Storage to create new objects of this type, there will be the default ones, that I described above, and there will be also the option to create new ones and save them to use later, on another time that app is launched, but that its fine, I already read something about how to serialize the object and use internal storage to keep them :)
I am just here asking about the first question, create the item only once at the beginning, maybe on the install moment of the app? I was assuming.. but dont know if its possible.
It has been very helpful to have this space for over an year, I have already learned a lot here from you thank you ;)
Android provides following intent to detect app installation
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
If you use these with conjunction with broadcast receiver you will be notified when user install a new app. Problem with this solution is, it will not help you as you are trying to detect your own app installation.
What you could do is every time user launch your app
check if object exist
if not create one and write it to internal storage.
in this way it will created once. Depend on type of object you are trying to save you might consider using SharedPreferences or SqlLite or simply a file IO. If you are writing Java Object yes serialization is the way to go.
Update
If you are planning to get data from network for the first time, depend on the size you can decide,
Small File: Put it inside Asset folder and ship it with apk.
large file: if the file size is huge you might consider to ship portion with apk and sync and update rest on a background process or download everything from network
I'm not sure what you mean. A Java object exists in memory, so "saving" it when the user installs the app makes little sense. It can't remain in memory unless some process is holding onto it.
If you mean something like a JPEG photo or other data, you can put the data in the directories of your project and then access it as a resource once your app is installed. See the
Providing Resources API guide.
I use an application on my samsung tablet (gt-p1000) that must store some settings somewhere and sometime I have to erase the application data to unlock the app, but this way too much things are removed then I would like to just remove the files that store specific informations.
Where can I find them or maybe how to edit some registry keys ?
THanks
You should use the same mechanism that you used to store your data. It's not clear from your question what you do, but I can think of 2 things:
if you use preferences, then you need to clear them the same way you set them (as they're not stored in a file as you think of it, it's more like a database)
if you store actual files, then you should know the directory, as you wrote a file in it.