Saving Data Privately On Device - android

I have files that I want to save so they are not accessible by other applications and that are safe from updates (won't be deleted).
My Problem
I am not sure where to save them. I know that I can save them in the data directory using the below code to get the path but I'm not sure if this is correct.
Environment.getDataDirectory();
My Question
Is the applications data directory the correct place to store my data or is it meant just for system data?
If it isn't the correct place, could you suggest where is?
Thanks in advance

I'm sure you have already come across this
http://developer.android.com/guide/topics/data/data-storage.html
In that you see Internal storage is usually a methodology which helps in achieving what you asked for. Yes you can use the function which you have shown
or
(OWNERACTIVITY).getFilesDir().getAbsolutePath()
should give you the location where data for the application gets stored.

If you are keeping files in SD card, all applications (with android.permission.READ_EXTERNAL_STORAGE) can access the data. The best place is is keep them in your data directory. Your application can access the data as long as your package name and certificate is not changed. If you want to store some files like images and audio, you can store them in SD card in a directory with .nomedia in it. But if you want to keep some data files, checksums etc, it is better to keep them in data directory. Even if you update your application, you should still be able to access it.
YOu can read more here

Related

Android save confidential file

Currently I am working on an app which has files stored in the res/raw folder.As I understood, these files are only readable but not writable?
My problem is that I need to change this files, when someone puts in a serial number, so that certain functionalists will be activated.
Also I do not really like to put the files as public on the SD card, since the users should not be able to get the content of these files.
How can I achieve this problem?
First thought would be:
The serial number and other settings information I am storing in the shared preferences...
Also my question is, are the shared preferences accessible for the user, so that he can see, change those settings by himself?
If not then I could store the information to activate the functionalists in there.
Does anyone has some other suggestions?

Best way to organize editable internal data files for Android app?

I want to use data from an xml file to populate AutoCompleteTextViews and MultiAutoCompleteTextViews, and I also want to be able to edit this file while the app is running so that the AutoCompleteTextViews can be updated with new information. What is the best way to go about this? I know that files in the /res folder cannot be written to during runtime, and writing to external storage is slower than accessing internal storage.
One way you could do this is by creating your own SQLite database.
I would make sure that the scope of what you are doing merits a database, though.
The other option is just to create a flat file with keyValuePairs and look up the value with the view's ID as the key. This could be stored in external storage. Access speed should not be a big concern for a text file.

folder which is on external memory(SD card) should be accessible only to specific android app.....Is there a way?

Actually my android app takes images and stores into external storage rather than internal memory because of space constraints. the images must be available only to that particular application only
Though datas in sd card are accesscible by all application, I want my images to be stored in external but it must be secure that no other app should use those images.
Is there a way that i can programmatically protect that specific folder with password if so only that android application can use the folder contents??
Another question if i store my application database itself in external memory. will the database can be accessible by another application?
Pls help me in this
Thanks in advance
The only way to ensure that is to install the application on the SDCard directly. All private data will be stored there then (invisible to anyone but you).
To do so, just put this parameter in the AndroidManifest file, at "manifest" tag:
android:installLocation="preferExternal"
Have you tried using -
SQLiteDatabase.openOrCreateDatabase(String, SQLiteDatabase.CursorFactory)
You can simply pass "/sdcard/info.db" as the first and null as the second parameter.
And go through on google search you can get many applications which are used to protect file by user's password.

Android save app settings/data in Internal/External Storage

I need a little help with understanding what can I do and cannot in android. I'm working on application which needs to ask user in first start to select a device (internal/external storage) where to save the data which my application is downloading over internet. So I'm trying to find answer for a few questions about this issue :
Is there any limit for data in internal/external storage in Android for a single application.
Can I set the directory of sqlite database which my app is using and If I can, is it a good practice or not.
What should I consider when user decide to change the destination of application's data from internal to external storage. Should I create all the folders and etc. again or Android platform is doing it automatically?
Thanks in advance!
Your limit on external storage(SDCARD) is determined only by its capacity, I'm not sure about the internal storage, maybe it's the same situation.
You can extend SQLiteOpenHelper and create your own DB adapter, which will manage your database and store it on SD card or /data/databases directory. I think that it's better not to place database on SDCARD, because any other app can access it there. On the other hand, /data/ folder is private.
It's tricky thing. You should be careful while copying data. Check whether directory of file exist, before writing into them. It's better to explicitly create all files and directories before trying to write to them.
Here is a good example of Database Helper for accessing database. You can modify it so it can use both external and internal storage.

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