making a File object does not create the actual file. usually it's created with a FileOutputStream or File.createNewFile() or somesuch.
as always, reading the docs pays dividends :-) also i'd recommend writing some little Java command line programs to get the feel of things. that way you don't have to deploy to the (relatively) hostile environment of the phone just to figure out stuff like File. hth >Anyone?? > >On Jul 14, 9:09 am, doubleminus <[email protected]> wrote: >> Isn't that what the first lines of code do? >> >> File file1 = new File(Environment.getExternalStorageDirectory(), >> file_name); >> >> On Jul 13, 3:02 pm, Streets Of Boston <[email protected]> wrote: >> >> >> >> > Simple. :-) >> > The error says that the file does not exist... that means you should >> > create it. >> > Use File#createNewFile(). >> >> > On Jul 13, 5:53 pm, doubleminus <[email protected]> wrote: >> >> > > Romain is? I don't understand. Is there something I should be doing >> > > to avoid filenotfound exception? >> >> > > On Jul 13, 12:40 am, ÷£‘ƒ <[email protected]> wrote: >> >> > > > You are right... >> >> > > > > Date: Sun, 12 Jul 2009 21:29:28 -0700 >> > > > > Subject: [android-developers] Re: >>Unable to write text file to sdcard on >>physical G1 device >> > > > > From: [email protected] >> > > > > To: [email protected] >> >> > > > > Hi, >> >> > > > > Instead of: >> >> > > > > > FileOutputStream file_out = openFileOutput >> > > > > > (file_name,MODE_WORLD_READABLE); >> >> > > > > Just use: >> >> > > > > FileOutputStream file_out = new FileOutputStream(file_name); >> >> > > > > This should work. >> >> > > > > On Sun, Jul 12, 2009 at 8:10 PM, >>doubleminus<[email protected]> wrote: >> >> > > > > > I need to write a fairly simple .csv >>file to the device's sdcard (so >> > > > > > it can then be emailed via Intent). >>The below code does not write the >> > > > > > file. >> >> > > > > > File file1 = new File(Environment.getExternalStorageDirectory(), >> > > > > > file_name); >> > > > > > FileOutputStream file_out = openFileOutput >> > > > > > (file_name,MODE_WORLD_READABLE); >> > > > > > BufferedOutputStream buf = new BufferedOutputStream(file_out); >> > > > > > OutputStreamWriter out_stream = new OutputStreamWriter(buf); >> >> > > > > > // write fields in first >>row of spreadsheet then a new line >> > > > > > for (int i = 0; i < FIELDS.length; i++) >> > > > > > { >> > > > > > if (i != FIELDS.length - 1) >> > > > > > out_stream.write(FIELDS[i] + ","); >> > > > > > else >> > > > > > out_stream.write(FIELDS[i]); >> > > > > > } >> >> > > > > > out_stream.write("\n"); >> >> > > > > > // more code here >> >> > > > > > I flush and close out_stream. I can >>even seem to be able to read from >> > > > > > the file on the device (printing >>above output, using fileinputstream, >> > > > > > to an edittext. >> >> > > > > > How can I get to this file on the sdcard? >> >> > > > > > Thanks! >> >> > > > > > double >> >> > > > > -- >> > > > > Romain Guy >> > > > > Android framework engineer >> > > > > [email protected] >> >> > > > > Note: please don't send private >>questions to me, as I don't have time >> > > > > to provide private support. All such questions should be posted on >> > > > > public forums, where I and others can see and answer them >> >> > > > _________________________________________________________________ >> > > > MSN >>ï\èÓñÇñ@ ÈÅC⸱”ßAìI 'ªƒ ±ë“ÅIhttp://im.live.cn/emoticons/-Hidequoted >>text - >> >> > > - Show quoted text - > -- jason.software.particle --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

