What file storage technology does the Android SDK support?
Sharedpreferences, stream file storage, XML semi-structured storage, JSON storage, database, third aspect to the object database.
How do I access key-value type of data using Shardpreferences?
Instantiate the Sharedpreferences object (first step) sharedpreferences mysharedpreferences= getsharedpreferences ("Test", Activity.mode_ PRIVATE); Instantiate the Sharedpreferences.editor object (step two) Sharedpreferences.editor Editor = Mysharedpreferences.edit (); Save the data editor.putstring ("name", "Karl") with putstring method; Editor.putstring ("Habit", "sleep"); Submit Current Data editor.commit ();
Similarly, an Sharedpreferences object is instantiated before reading sharedpreferences data sharedpreferencessharedpreferences= getsharedpreferences ( "Test", activity.mode_private); Use the GetString method to get value, note that the 2nd parameter is the default value of String name =sharedpreferences.getstring ("name", "" "); String habit =sharedpreferences.getstring ("Habit", "" "); Display information using the Toast Information prompt box
In which directory is the sharedpreferences saved data file stored? Can I read these data files without using sharedpreferences?
File storage path is Data/data/packagename/shared_prefs
You can read files directly with a file stream.
Sharedpreferences can I save the data on my SD card?
You can modify the file save path with Java reflection technology.
Sharedpreferences can I save image data?
To convert an image to binary data:
Public byte[] Getbitmapbyte (Bitmap Bitmap) {bytearrayoutputstream out = new Bytearrayoutputstream (); Bitmap.compress (Bitmap.CompressFormat.JPEG, N, out); try {out.flush (); Out.close (); } catch (IOException e) {e.printstacktrace (); } return Out.tobytearray (); }
Read:
Public Bitmap getbitmapfrombyte (byte[] temp) {if (temp! = null) {Bitmap Bitmap = Bitmapfactory.decodebytearra Y (temp, 0, temp.length); return bitmap; }else{return null; } }
How do I implement the Settings page via preferencesactivity?
Http://www.jb51.net/article/31915.htm
Preferenceactivity What is the default file name for saving data? How do I change it?
Packagename_preferences.xml.
Modified with the Preferencemanager.getsharedpreferencesname method.
What does the Android SDK support for getting file input and output streams?
1:inputstream and OutputStream Way.
http://blog.csdn.net/ztp800201/article/details/7322110
2:context.openfileoutput and Context.openfileinput objects.
Http://blog.sina.com.cn/s/blog_6e5195850100zssn.html
What is the SAX engine's process of parsing XML documents?
Initialize--start processing each XML element--Process the elements--finish the file, finish finishing the work--Save the text of the XML element
How do I convert an XML file to a Java object?
http://showlike.iteye.com/blog/1050843
Android Interview Cookbook study notes (fifth: file storage)