Some of the application's configuration files need to be stored on the phone. Generally divided into internal storage and SD card storage.
One. Internal storage, to FileOutputStream
New File (Getfilesdir (), "User.txt"); // Open local File preparation record Try { new fileoutputstream (file); Fos.write (User+ # # # +pass). GetBytes ()); Fos.close (); } Catch (Exception e) { // todo:handle Exception }
Two. External storage
Just change the stored path: file file= new file (Environment.getexternalstoragedirectory (), "user.txt");
Determine SD card status
if (Environment.getexternalstoragestate (). Equals (environment.media_mounted)) {
}
File file=NewFile (Environment.getexternalstoragedirectory (), "User.txt"); if(File.exists ()) {Try{FileInputStream fis=Newfileinputstream (file); BufferedReader BR=NewBufferedReader (NewInputStreamReader (FIS)); String text=Br.readline (); String [] s= Text.split ("# # #"); Ed_user.settext (s[0]); Ed_pass.settext (s[1]); }Catch(Exception e) {//Todo:handle Exception}
Android internal storage and external storage