我正在尝试从dropbox Photos文件夹下载文本文件。这是正确的做法吗?因为我得到一些警告,因为我猜它没有下载文件
public void onClick(View v) {
File mFile=new File(Environment.getExternalStorageDirectory().getPath() + "Download1");
try {
FileOutputStream mFileOutputStream=new FileOutputStream(mFile);
DropboxFileInfo mDropboxFileInfo=mApi.getFile("/Photos/"+"fileGhh", null, mFileOutputStream, null);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DropboxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
这是Logcat
11-22 15:40:51.369: W/System.err(24394): java.io.FileNotFoundException: /mnt/sdcardDownload1: open failed: EROFS (Read-only file system)
11-22 15:40:51.369: W/System.err(24394): at libcore.io.IoBridge.open(IoBridge.java:419)
11-22 15:40:51.369: W/System.err(24394): at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
11-22 15:40:51.369: W/System.err(24394): at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
11-22 15:40:51.369: W/System.err(24394): at com.example.screenwritter.Dropboxdowload$2.onClick(Dropboxdowload.java:135)
11-22 15:40:51.369: W/System.err(24394): at android.view.View.performClick(View.java:3574)
11-22 15:40:51.369: W/System.err(24394): at android.view.View$PerformClick.run(View.java:14293)
11-22 15:40:51.369: W/System.err(24394): at android.os.Handler.handleCallback(Handler.java:605)
11-22 15:40:51.369: W/System.err(24394): at android.os.Handler.dispatchMessage(Handler.java:92)
11-22 15:40:51.369: W/System.err(24394): at android.os.Looper.loop(Looper.java:137)
11-22 15:40:51.369: W/System.err(24394): at android.app.ActivityThread.main(ActivityThread.java:4448)
11-22 15:40:51.369: W/System.err(24394): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 15:40:51.369: W/System.err(24394): at java.lang.reflect.Method.invoke(Method.java:511)
11-22 15:40:51.369: W/System.err(24394): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
11-22 15:40:51.369: W/System.err(24394): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
11-22 15:40:51.369: W/System.err(24394): at dalvik.system.NativeStart.main(Native Method)
11-22 15:40:51.369: W/System.err(24394): Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
11-22 15:40:51.379: W/System.err(24394): at libcore.io.Posix.open(Native Method)
11-22 15:40:51.379: W/System.err(24394): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
11-22 15:40:51.379: W/System.err(24394): at libcore.io.IoBridge.open(IoBridge.java:403)
答案 0 :(得分:0)
不是100%肯定,但我猜你想要Environment.getExternalStorageDirectory().getPath() + "/Download1"
。 (注意Download1
之前的前导斜杠。)
这是基于错误,似乎是试图写入/mnt/sdcardDownload1
。 /mnt/sdcard/Download1
对我来说似乎是一条更好的道路。