I'm trying to email out a file using intents and content providers.
I've hit a road block with the below code.  It crashes gmail.  I think
it may have something to do the attachment having a size of 0
according to the gmail app.

Yea I now I can save it to the sd card, but I'd like to do it without
leaving files around the external drive.

@Override
   public ParcelFileDescriptor openFile(Uri uri, String mode) throws
FileNotFoundException {

         //get string
        String text = new String("test");

        //save to disk
        ParcelFileDescriptor fd = openFile(Uri.parse ("file://test.csv"),
"r");
        FileOutputStream fos = new FileOutputStream(fd.getFileDescriptor
());
        OutputStreamWriter out = null;


        try {
                out = new OutputStreamWriter(fos, "UTF-8");
        } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
        }


        try {
                //outputs start,stop,duration,apart
                out.write(text);
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }


                try {
                        out.flush();
                        out.close();

                        fos.flush();
                        fos.close();

                        fd.close();
                } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                }


           File file = new File("test.csv");
       ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file,
ParcelFileDescriptor.MODE_READ_ONLY);
       return parcel;
   }

The code runs fine, except for gmail crashing on sync.  It was a good
lesson, just clear your cache to get it working again!  :-)

Thanks for any help!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to