My android application is getting large and we want to store it in SD CARD. can i store shared preference in SD CARD along with my application
You cannot modify where shared preferences are stored. Since shared preferences are simply stored in an XML file, you are welcome to read and write XML data on external storage as you see fit.
Related
When My application is running I want to capture some information and save this to a folder in my application rather than to the device. I have read online that it is not possible to save a file to your assets or res directory. However would it be possible to save it to another file in your application?I had a look at Shared Preferences but that seems to be only for Key Value pairs.
http://developer.android.com/guide/topics/data/data-storage.html
Writing to internal storage with MODE_PRIVATE should handle what I think you want..
You cannot store the files in the Assets or the Raw folder at run time.
Instead if you have image/video/audio/textual files you can store the files in your SD card and store the path of those files in your file in Database or shared preferences.
After installation each application creates a storage located in '/data/data/com.your.app.package.name'. Save whatever you want in that place.
Can anyone help me ? Is it possible to create shared preference files in sdcard rather than on private path of an android application.
You cannot modify where shared preferences are stored.Its a private storage. if you want to use sd card use
Environment.getExternalStorageDirectory(). and get the path of directories stored in sdcard.
it is possible by reading&writing the xml file into the external storage ,but it's not the same as sharedPreferences. you will have to implement your own way , or use the android code of this class.
however , there are some disadvantage over using the internal storage:
anything you store on the sdcard is visible to every application and the end user can read it by just opening it.
only in the internal storage you get some sort of protection against reading the file , so that only rooted devices can read the files.
external storage can also be unmounted , so the data can sometimes be unreachable. you need to handle possible errors that can occur because of this.
uninstalling the app while the sd card is mounted means that the data will stay on the sdcard .
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.
I am developing an android application. In my application, I am displaying images from url using xml parsing. I want to store images in device's Shared Preferences. How can I store image in shared preferences and retrieve image from shared preferences? How is it possible?
Thanks All.
I'll try to give you an idea, i use to store temporary object using shared preference, so use kind of serialization, i wrote my own Base64 Encoder/Decorer and basically.
Step 1) Encode your Bitmap or JP..etc
Step 2) Put it in Shared pref as string. (encoded string)
Step 3) Retrive your Encoded object from SharedPref
Step 4) Decode it and you will have your object Back (your pic).
It's not that hard to do it.
Why would you store it in the SharedPreferences? That is not the correct location for storing images.
You should cache them on the external storage if one is available and if not then you should try to store them on the internal storage but watch out when working with the internal storage as you generally won't have as much space as on the external storage.
Check out this article on using the external storage.
I want to change the android sharedPreferences save path,the sharedPreferences save in /data/data/xxx.xxx.xxx/shared_prefs,i want to change path to /sdcard. how i do?
You cannot modify where shared preferences are stored. Since shared preferences are simply stored in an XML file, you are welcome to read and write XML data on external storage as you see fit.
BTW, never use /sdcard. Use Environment.getExternalStorageDirectory(). /sdcard is not the correct path for over a third of existing Android devices.