开发者

How to read/write data to mounted sdcard

开发者 https://www.devze.com 2023-01-11 05:15 出处:网络
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.

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("/s开发者_StackOverflow中文版dcard/Test/test.txt");

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

         buf.write(str.getBytes());

Thanks,

Nicholas


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

0

精彩评论

暂无评论...
验证码 换一张
取 消