Writing a file. Java. Android -


 final string rootpath = environment.getexternalstoragedirectory().getabsolutepath() + "/slots/";     final file file = new file(rootpath);     file.mkdirs();     final file sdfile = new file(file, "profile.txt"); try {     bufferedwriter bw = new bufferedwriter(new filewriter(sdfile));     bw.write(edit.gettext().tostring() + "\n");     bw.write("5000");     } catch (ioexception e) { } 

in code catches ioexception, file created. please! answers.

try this:

 final string rootpath = environment.getexternalstoragedirectory().getabsolutepath() + "/slots/";  final file file = new file(rootpath);  file.mkdirs();  final file sdfile = new file(file, "profile.txt"); try {         filewriter fw = new filewriter(sdfile);         bufferedwriter bw = new bufferedwriter(fw);         bw.write("hello "+"\n");         bw.write("5000");         bw.close();     } catch (ioexception e) {         log.e("exception ",e.getmessage());     } 

make sure add permission in manifest file:

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

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -