Android Dropbox上传/下载应用程序到SD卡

时间:2016-07-07 15:19:29

标签: java android dropbox

我正在尝试创建一个将文件上传到Dropbox并下载它的应用。 上传似乎工作,下载没有。它实际上并不是从我的SD卡上传,而是从我的手机内存上传。

saveOnDropbox()将phone.txt从phone / MyFiles / file.txt上传到dropbox app文件夹。

saveOnDevice() - 当我使用它时会发生一些事情,但该文件既没有到达我的手机或SD卡

public void saveOnDropBox() throws IOException, DropboxException {


    File sdCard = Environment.getExternalStorageDirectory();
    File file = new File(sdCard.getAbsolutePath() + "/MyFiles/file.txt"); 
    FileInputStream inputStream = new FileInputStream(file);
    DropboxAPI.Entry response = dropboxAPI.putFile("/file.txt", inputStream,
            file.length(), null, null);


    Log.i("D bExam pleLog", "The uploaded file's rev is: " + response.rev);
}





public void saveOnDevice() {

    FileOutputStream outputStream = null;
    try {
        File sdCard = Environment.getExternalStorageDirectory();

        File file = new File(sdCard.getAbsolutePath() + "/MyFiles/file.txt");
        outputStream = new FileOutputStream(file);

        DropboxAPI.DropboxFileInfo info = dropboxAPI.getFile("/file.txt", null, outputStream, null);


    } catch (Exception e) {
        System.out.println("Som ething w ent w rong: " + e);
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                System.out.println("___" + e);
            }
        }
    }
}}

感谢任何帮助。

0 个答案:

没有答案