Write/read the xxx.txt file under the Data/data/package directory.
1/** read/write the file data stored internally */2 findviewbyid (R. id. btnwrite ). setonclicklistener (3 new view. onclicklistener () {4 @ override 5 Public void onclick (view v) {6 try {7 fileoutputstream FAS = openfileoutput ("text", 8 context. mode_private); 9 outputstreamwriter ASW = new outputstreamwriter (10 Fas, "UTF-8"); 11 ASW. write (ET. gettext (). tostring (); 12 ASW. flush (); 13 FAS. flush (); 14 ASW. close (); 15 FAS. close (); 16 toast. Maketext (getapplicationcontext (), "write complete. ", 17 toast. length_short ). show (); 18} catch (filenotfoundexception e) {19 E. printstacktrace (); 20} catch (unsupportedencodingexception e) {21 E. printstacktrace (); 22} 23} 24}); 25 findviewbyid (R. id. btnread ). setonclicklistener (26 new view. onclicklistener () {27 @ override28 public void onclick (view v) {29 try {30 fileinputstream ISI = openfileinput ("text"); 31 inputstreamreader is = new inputstreamreader (FCM, 32 "UTF-8"); 33 char input [] = new char [FCM. available ()]; 34 is. read (input); 35 is. close (); 36. close (); 37 string readed = new string (input); 38 show. settext (readed); 39} catch (filenotfoundexception e) {40 E. printstacktrace (); 41} catch (ioexception e) {42 E. printstacktrace (); 43} 44} 45 });