Nicholas
Nicholas

Reputation: 21

How to read/write data to mounted sdcard

is there any way to write data to a sdcard when the card is mounted as a disc via usb?

I get an permission denied exception. If I unplug it everything is fine.

I know I should be using Environment.getExternalStorageDirectory, but I don't think this would make any difference.

Code:

        File file = new File("/sdcard/Test/test.txt");

        BufferedOutputStream buf = new BufferedOutputStream(
                 new FileOutputStream(file,true));

         buf.write(str.getBytes());

Thanks,

Nicholas

Upvotes: 1

Views: 1342

Answers (1)

Loxley
Loxley

Reputation: 1781

No, there isn't. Only one OS may use the sdcard(-partition) at any time.

Upvotes: 5

Related Questions