java - Android csv file creation and editing -


i have been working on few weeks little bit @ time. android app developing multiple versions of samsung tablets. need create file , add text it. cannot either. have 2 different methods add text using different text writers add text file. here code:

public void addtexttofile(string text) { file logfile = new file(environment.getexternalstoragepublicdirectory(environment.directory_podcasts), "myfile.csv"); if (!logfile.exists()) {     try {         logfile.createnewfile();     } catch (ioexception e) {         e.printstacktrace();     } } try {     bufferedwriter buf = new bufferedwriter(new filewriter(logfile, true));     buf.append(text);     buf.newline();     buf.close(); } catch (ioexception e) {     e.printstacktrace(); } } public void write(string data){ outputstream os; outputstreamwriter osw; data += "\n"; try {     os = new fileoutputstream(file, true);     osw = new outputstreamwriter(os);     osw.write(data);     osw.flush();     osw.close(); } catch (exception e) {     e.printstacktrace(); } } 

found error, did research @ beginning , thought did not need permission create publicly view-able file, gave myself permission in android manifest so:

<uses-permission android:name="android.permission.write_external_storage" /> 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -