ImportJava.io.ByteArrayOutputStream;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException;Importorg.apache.http.util.EncodingUtils;Importandroid.app.Activity;ImportAndroid.content.Context;/*** Write and read data at./data/data/packagename/files/* *@authorYurf*/ Public classFilecache {/*** Write file to./data/data/packagename/files/* *@paramfilename * filename *@parammessage * String to save *@paramContext*/ Public Static voidwritefiledata (String fileName, String message, Context context) {string content=message; Try{FileOutputStream OutputStream=context.openfileoutput (FileName, activity.mode_private); Outputstream.write (Content.getbytes ()); Outputstream.flush (); Outputstream.close (); } Catch(FileNotFoundException e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); } } /*** Write file to./data/data/packagename/files/* *@paramFileName *@paramvalues *@paramContext*/ Public Static voidWritefiledata (String FileName,byte[] values, context context) { Try{FileOutputStream OutputStream=context.openfileoutput (FileName, activity.mode_private); Outputstream.write (values); Outputstream.flush (); Outputstream.close (); } Catch(FileNotFoundException e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); } } /*** Read file from./data/data/packagename/files/* *@paramFileName *@paramContext *@return */ Public Staticstring Readfiledata (string fileName, Context context) {string content= ""; Try{FileInputStream InputStream=Context.openfileinput (fileName); Bytearrayoutputstream Arrayoutputstream=NewBytearrayoutputstream (); intLength =inputstream.available (); byte[] bytes =New byte[length]; Inputstream.read (bytes); Arrayoutputstream.write (Bytes,0, bytes.length); Inputstream.close (); Arrayoutputstream.close (); Content=encodingutils.getstring (Arrayoutputstream.tobytearray (),"UTF-8"); } Catch(FileNotFoundException e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); } returncontent; }}