Android Access txt

Source: Internet
Author: User

/** 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.