Recommended locations to store app licence file and database? - android

Where would the recommended location be to store an app licence file and a SQLite database for Android? Also, what are the constants used to point to those locations?
Note that the location(s) must be accessible without having to root the device, so the app data folder is not an option. I need to be able to access the files via a PC using a standard file manager.
I noticed that on the root folder of the device, there is a folder called "db" where other apps seem to store data. Is that a good location to store my db? If so, what is the Environment constant that points to it?

Depending on the level of security you want to achieve, there are numerous approaches to this issue.
At it's simplest you could store them at any folder on you external storage(Documents,Downloads e.t.c) or on your SD card provided that the user has given you permission AND has himself selected the path since newer Android Versions have reworked(restricted) the way an app can read/write from/to an SD card.
If for example you want to store it to "documents" folder you could do the following:
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),".dir");
This selects the "Documents" folder and creates a folder called dir. Note the "." before "dir" , meaning that the folder will be invisible as a first level of security. From here on you can create any number of directories or files you desire.

Related

How to restrict user from viewing/accessing the cached files from file explorer in an Android Device?

My requirement is to cache the files securely in android internal/external storage, where apps other than my app should not view/access the documents I store.
Current implementation:
Currently, the app uses context.getExternalCacheDir() as a base directory and followed by respective folder structure to cache files. The problem here is, any user can view the files stored by just navigating through the path using some File Explorer apps.
We can use context.getCacheDir() or file directory,
There are limitations in using it, as it has less space and the platform might automatically delete files when it wants space for other operations.
Required Implementation:
Encryption/decryption would be one way yet, please suggest other possible ways to cache the files securely, so that users cannot view/access using other external applications.
as it has less space
That is not true for most Android devices created in the last 8 years.
the platform might automatically delete files when it wants space for other operations
That also holds true for getExternalCacheDir().
please suggest other possible ways to cache the files securely, so that user cannot view/access using other external application
Use getFilesDir().

Android Storage access framework

I am writing a file encryption app.
I set up the file(s) browse code using the default storage directory.
This works great, I wrote the code to be able to encrypt multiple files as well as directories.
Directories simply get copied, and the files within are encrypted into a new directory.
The problem is now after some research I have found that I need to utilize the storage access framework to be able to select files from external sd cards, and any other storage system the user may have.
My question is, is there a way to select multiple files and folders simultaneously through activities in the saf? Is there a workaround for this? I found an activity that is able to select multiple files, and I found one that allowed me to select a single directory.

How to delete all the files stored in Environment.getExternalStorageDirectory() in android

As the question states:
My application has created some files in
Environment.getExternalStorageDirectory()
I have to delete all the files of my application in that
Environment.getExternalStorageDirectory() location
How to do this
Note: It must not delete other files created by other application
Use the delete() method on the File object for each file to be deleted.
You will need to determine for yourself what files are to be deleted. Nobody else will know, including Android. There is no app-specific ownership information on files on external storage, even if such data would necessarily be reliable for your use case.
Also, bear in mind that each account on Android gets its own part of external storage, and you can only delete files that are in the external storage for whatever account it is that is presently running. Other accounts (on Android 4.2+ tablets and Android 5.0+ phones) are not accessible to you.

The best place to store a user-accessible configuration file

I have a project consisting of four programs for different platforms; all of them use the same XML-based settings file format. I want to be able to manually modify/overwrite it outside of the application. On Windows, Windows Mobile and Linux I'm using "user.home", but on Android that alias isn't implemented. I'm thinking about simply putting it in the Downloads directory, however, that doesn't feel right.
I can't be the only one, who needs that kind of functionality. Or this isn't Android-way? Any suggestions are appreciated.
EDIT: I'm OK with the settings file not being available all the time (i.e. SD-card removed), it's used only on the start-up of the application.
Store it in getExternalFilesDir(). This would work only if the device has an external storage. The user would be able to access it.
However, take note of the following from the docs:
External files are not always available: they will disappear if the
user mounts the external storage on a computer or removes it. See the
APIs on Environment for information in the storage state.
According to Android data storage documentation you have 5 options:
Shared Preferences. By default this will use file /data/data/your.package.name/preferences/user_preferences.xml
Internal Storage. Here you can use something like /data/data/you.package.name/user.home
External Storage. Similar to internal storage /mnt/sdcard/Android/data/your.package.name/user.home, but if user removes memory card file will be inaccessible.
SQLiteDatabase. You can store the whole user.home file in a database blob.
NetworkConnection. Store user's config in a cloud.

How do I access my app's package folder in Android using Adobe AIR / Flex?

I have an application for Android built using Flex. I need to save some configurations and data so I want to know how I can access the package-specific folder for my app instead of creating my own folder and writing there.
The package-specific folder I'm talking about is at /sdcard/Android/data/com.mysite.myapp/. Do I just access it directly via that path or is there a variable for File class that I'm not aware of?
The reason why I want to save onto this folder is because, if I create my own folder and save there, that would require my app to request the permission to access SD card contents. Something I don't want to include in my permission list.
For app specific files, you can choose either applicationDirectory (read only), or applicationStorageDirectory.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html

Categories

Resources