Where, specifically, are you getting this error?

If this is the emulator, do you have any external storage set up? By
default, there is none.

On Sun, Jun 12, 2011 at 11:37 AM, Ab Caballero <[email protected]> wrote:
> Still getting the same error. I followed your advice with:
>
> File sdDir = Environment.getExternalStorageDirectory();
> sdDir.mkdirs();
> File file = new File(sdDir +currentTripName+".kml");
> FileWriter sdWriter = new FileWriter(file, false);
> sdWriter.write(fileContents);
> sdWriter.close();
>
> also, the manifest includes:
> <uses-permission
> android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
> which i have placed outside of the application tags.
>
> On Jun 12, 11:09 am, Mark Murphy <[email protected]> wrote:
>> Never never never hardwire paths. For example, your paths are wrong
>> for modern versions of Android. Use
>> Environment.getExternalStorageDirectory() for the root of external
>> storage.
>>
>> Also, make sure you have the WRITE_EXTERNAL_STORAGE permission.
>>
>>
>>
>>
>>
>> On Sun, Jun 12, 2011 at 10:31 AM, Ab Caballero <[email protected]> wrote:
>> > I am attempting to save data to the sdcard with the following code but
>> > get a file not found exception:
>>
>> > String fileContents = fileBuf.toString();
>> > Log.d(tag, fileContents);
>> > File sdDir = new File("/sdcard/Logger");
>> > sdDir.mkdirs();
>> > File file = new File("/sdcard/Logger/"+currentTripName+".kml");
>> > FileWriter sdWriter = new FileWriter(file, false);
>> > sdWriter.write(fileContents);
>> > sdWriter.close();
>>
>> > When i try the following code (API level 8), I get a similar error.
>>
>> > File sdDir = getExternalFilesDir(null);
>> > File file = new File(getExternalFilesDir(null) + currentTripName
>> > +".kml");
>> > FileWriter sdWriter = new FileWriter(file, false);
>> > sdWriter.write(fileContents);
>> > sdWriter.close();
>>
>> > Any suggestions? This is driving me nuts.
>>
>> > --
>> > 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
>>
>> --
>> Mark Murphy (a Commons 
>> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>>
>> Android Training in NYC:http://marakana.com/training/android/
>
> --
> 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
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in NYC: http://marakana.com/training/android/

-- 
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

Reply via email to