android - trying to open the sdcard's .txt file in my EditText -


i trying open sdcard's .txt file in edittext change text in , save changes using button click not going in right way .may know correct way achieve objective?

            try one..  must set permission in manifest file:  <uses-permission android:name="android.permission.write_external_storage"/>              file f = new file(environment.getexternalstoragedirectory().getabsolutepath()                          + "followed ur file dir");           file f = new file(environment.getexternalstoragedirectory().getabsolutepath()                          + "sdcard.txt");            (file wavfile : f.listfiles())          {             string str = wavfile.getname().tostring();             stringbuffer stringbuffer = new stringbuffer();                             string adatarow = "";                           string abuffer = "";                           try {                               file myfile = new file("/sdcard/"+filename);                               fileinputstream fin = new fileinputstream(myfile);                               bufferedreader myreader = new bufferedreader(                                       new inputstreamreader(fin));                                while ((adatarow = myreader.readline()) != null) {                                   abuffer += adatarow + "\n";                               }                               myreader.close();           edtitext.settext(abuffer.tostring());                          } catch (ioexception e) {                               e.printstacktrace();                           }                      toast.maketext(getapplicationcontext            (),abuffer,toast.length_long).show();                        }                }         again btnclick have write edited string right..            use 1 write in file..         fileoutputstream fos;                              try {                                  file myfile = new file("/sdcard/"+sdcard.txt);                                   myfile.createnewfile();                                   fileoutputstream fout = new             fileoutputstream(myfile);                                   outputstreamwriter myoutwriter = new             outputstreamwriter(fout);                                   myoutwriter.append(data);                                   myoutwriter.close();                                   fout.close();                        toast.maketext(getapplicationcontext(),filename + "             saved",toast.length_long).show();                                } catch (filenotfoundexception e) {e.printstacktrace();}                              catch (ioexception e) {e.printstacktrace();}                        }         thank you...       more detalis ref link'      http://www.javatpoint.com/android-external-storage-example     ---------------------------------------------------------- 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -