/** take the SD card path **/private String Getsdpath () {File Sddir = Null;boolean sdcardexist = Environment.getexternalstoragestate (). E Quals (Android.os.Environment.MEDIA_MOUNTED);//Determine if the SD card exists if (sdcardexist) {Sddir = Environment.getexternalstoragedirectory ();//Gets the root directory}if (sddir! = null) {return sddir.tostring ();} else {return "";}} /** Save password file path **/private string getdirectory () {String dir = Getsdpath () + "/" + "Qqtsave"; File File = new file (dir), if (!file.exists ()) {try {file.mkdirs ();} catch (Exception e) {e.printstacktrace ()}} return dir;} private void Tosave (string user, string password) {File File = new file (getdirectory () + "/" + "us.txt"); if (!file.exists ( ) {try {file.createnewfile ();} catch (IOException e) {//TODO auto-generated catch Blocke.printstacktrace ();}} try {FileWriter fw = new FileWriter (file), Fw.write (user + "ASD" + password); Fw.close ();} catch (IOException e) {//TODO Au To-generated catch Blocke.printstacktrace ();}} Public String Read () {String sb = ""; BufferedReader br;try {br = new BufferedReader (New FileReader (getdirectory () + "/" + "US.txt")); String line = "", while (line = Br.readline ()) = null) {sb=line;} Br.close ();} catch (Exception e) {//TODO auto-generated catch Blocke.printstacktrace ();} LOG.E ("--------------", SB); return SB;} public void Deletesave (String user) {File File = new file (getdirectory () + "/" + "US.txt"), if (!file.exists ()) {try {file.c Reatenewfile ();} catch (IOException e) {//TODO auto-generated catch Blocke.printstacktrace ();}} try {FileWriter fw = new FileWriter (file), fw.write (user+ "null"), Fw.close ();} catch (IOException e) {//TODO auto-generate D catch Blocke.printstacktrace ();}}
Android Access txt