Also, you will need <uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />  in your
manifest, if you are using Android 1.6 and beyond.

On Mar 16, 10:33 pm, sumit asok <dont.follow.me....@gmail.com> wrote:
> I think openFileOutput() method is used to write to applications
> private data ( not the SD card )
> So your application will be searching for a folder /sdcard/ inside
> your applications folder "/data/...path to your application/"
> In order to write file you have to use FileOutputStream.
>
> On Mar 12, 5:43 am, Pradeep <pradeep.aro...@gmail.com> wrote:
>
>
>
> > Hi:
> >    I have the following code in my application. When loaded into the
> > phone, I get "File Open Exception". Any idea what I may be doing
> > wrong? I suspect some issue with permissions or something but I'm not
> > sure.
>
> > ========================= code snippet ====================
> >         FileOutputStream fos;
> >                 try {
> >                         fos = this.openFileOutput("/sdcard/demo.txt",
> > MODE_WORLD_WRITEABLE);
> >                         try {
> >                                 fos.write("Appended".getBytes());
> >                                 fos.close();
> >                         } catch (IOException e) {
> >                                 // TODO Auto-generated catch block
> >                         Toast.makeText(getBaseContext(),
> >                                 "File Write or Close Exception!!",
> >                                 Toast.LENGTH_SHORT).show();
> >                                 e.printStackTrace();
> >                         }
> >                 } catch (FileNotFoundException e) {
> >                         // TODO Auto-generated catch block
> >                 Toast.makeText(getBaseContext(),
> >                         "File Open Exception!!",
> >                         Toast.LENGTH_SHORT).show();
> >                         e.printStackTrace();
> >                 }
> > ===================================
>
> > Regards...Pradeep.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to