This is my study notes I just will csdn blog as a record of learning where so ...
</pre><span style= "FONT-SIZE:18PX;" >1. Create a FileOutputStream object by using the Openfileoutput () method Out</span><p></p><p><span style= " font-size:18px; " >2. Through the out new one OutputStreamWriter object </span></p><p><span style= "FONT-SIZE:18PX;" >3. By OutputStreamWriter object New one BufferedWriter object Writer</span></p><p><span style= " font-size:18px; " >4. Writing strings to a file by Writer.write (data) ps:data to String type </span></p><p></p><p>< Pre name= "code" class= "java" ><span style= "font-size:18px;" >public void Save () {string Datta= "I am a string"; FileOutputStream Out=null; BufferedWriter Writer=null; try{out=openfileoutput ("Data", context.mode_private); Writer=new BufferedWriter (New OutputStreamWriter (out)); Writer.write (data); }catch (IOException e) {e.printstacktrace (); }finally{try{if (writer!=null) {writer.close (); }}catch (IOException e) {e.printstacktrace (); }}}</span>
There are two parameters in the Openfileoutput () method. The first file name specified for you. The file name does not include the path (all files are stored by default in the/data/data/<packagename>/files/directory). The second parameter is the operation mode of the file, and there are two optional mode_private and mode_append. Mode_private is the default parameter, which means that when the same file name is specified, the content that is written overwrites the contents of the original file. Mode_append indicates that a new file is created if the file exists to append content to the file.
If we want to store the data in EditText, we first get an instance of EditText in OnCreate (), get the input in EditText in the Ondestory () method, and call the Save () method to store the input to a file.
=============================================================================================================== =====================
Writer must remember close (), or the data will not be stored in the file t_t
May 9, 2016
android--persistence technology for file storage