Hi Mark thanks for the reply, and yes i WRITE_EXTERNAL_STORAGE set like so:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses- permission> and i load the app onto my phone then disconnect the phone from my pc and then try my save function, still crashes. any ideas? On Apr 30, 3:15 pm, Mark Murphy <[email protected]> wrote: > emada.adame wrote: > > hi im just trying to save some text to a file on android and while it > > works fine on the emulator "dont crash", when i try it on my phone it > > crashes, what am i doing wrong? heres the code: > > > try{ > > File root = Environment.getExternalStorageDirectory(); > > if (root.canWrite()){ > > File file = new File(root, "file.txt"); > > FileWriter writer = new FileWriter(file); > > BufferedWriter out = new BufferedWriter(writer); > > out.write("some data"); > > out.close(); > > showMes("File saved."); > > }else{ > > showMes("Could not save file."); > > } > > }catch(Exception e){ > > showMes(e.toString()); > > } > > > i do know it crashes on " File root = > > Environment.getExternalStorageDirectory(); " > > That would be very surprising. > > Make sure you have the WRITE_EXTERNAL_STORAGE permission. Make sure your > device has an SD card installed, and that it is not mounted on the > development PC as a USB drive. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Consulting:http://commonsware.com/consulting > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

