Hi,
Try adding this code before you open the file....
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
gpxFilePath = new File(root, "abcd.txt");
....
....
}
-Vinay
On May 27, 1:29 pm, jp <[email protected]> wrote:
> Hi fellow developers, i'm having this issue of not being able write
> text file into the SDCard.
> I'm running the program through eclipse on a HTC magic version 2.1.
> i had the USB cable unplugged before i run the program.
> It says that the parent directory of file does not exist: data2/
> abc.text
>
> Can any1 help me on this, thanks in advance
>
> The button that trigger the saving
>
> btnSave.setOnClickListener(new View.OnClickListener() {
>
> public void onClick(View v) {
> try {
>
> boolean success = (new
> File("data2")).mkdir();
> if (success) {
>
> Toast.makeText(Test.this,
> "Success", Toast.LENGTH_SHORT).show();
>
> }
>
> File gpxfile = new File("data2/
> abc.txt");
>
> if(!gpxfile.exists()){
> gpxfile.createNewFile();
>
> FileWriter gpxwriter = new
> FileWriter(gpxfile);
> BufferedWriter out = new
> BufferedWriter(gpxwriter);
> out.write("b");
> out.close();
> Toast.makeText(Test.this, "Success2",
> Toast.LENGTH_SHORT).show();
> }
> }
> catch (IOException e) {
> Toast.makeText(Test.this, e+"",
> Toast.LENGTH_SHORT).show();
> }
> }
>
> });
> }
>
> i did add this permission in the manifest file
>
> <uses-permission
> android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
--
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