Data storage and access many times the software we develop needs to store the processed data for re-access. Android provides the following methods for data storage: · file · SharedPreferences (parameter) · SQLite database · Content provider · demonstrate file storage and reading in the Network: activity_main.xml [html] <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: orientation = "vertical"> <TextView android: layout_width = "fill_parent" android: layout _ Height = "wrap_content" android: text = "@ string/text1"/> <EditText android: id = "@ + id/filename" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: text = "abc.txt"/> <TextView android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: text = "file content"/> <EditText android: id = "@ + id/filecontent" android: layout_width = "fill_parent" android: layout_height = "wrap_con Tent "android: minLines =" 3 "/> <Button android: id =" @ + id/myButtonSave "android: layout_width =" wrap_content "android: layout_height =" wrap_content "android: text = "save"/> <Button android: id = "@ + id/myButtonRead" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = "read"/> </LinearLayout> FileServise. java [java] package com. example. service; import java. io. byteArrayOutputStrea M; import java. io. fileInputStream; import java. io. fileNotFoundException; import java. io. fileOutputStream; import java. io. IOException; import java. io. outputStream; import java. io. outputStreamWriter; import android. content. context; public class FileServise {/*** save file ** @ param filename * file name * @ param filecontent * file content * @ return */private Context context; public FileServise (Context context) {s Uper (); this. context = context;} public void savefile (String filename, String filecontent) throws IOException {/** IO technology is easy to write from my javase io stream, however, the Context object of android can be used to quickly obtain the output stream. The second parameter is * Private operation mode. The created file can only be accessed by this application. At the same time, files created in private mode will overwrite the content of the source file. */FileOutputStream fos = context. openFileOutput (filename, Context. MODE_PRIVATE); fos. write (filecontent. getBytes (); fos. close ();}/*** File Read ** @ param filename * @ return * @ throws IOException */public String readfile (String filename) throws IOException {FileInputStream FCM = context. openFileInput (filename); // Method for writing to memory ByteArrayOutputStream baos = new ByteArrayOutputStream (); byte [] buffer = New byte [1024]; int len = 0; while (len = Fi. read (buffer ))! =-1) {baos. write (buffer, 0, len);} // obtain byte [] data = baos. toByteArray (); return new String (data );}}