2

我无法将文件上传到 Dropbox。我没有收到任何错误,app 文件夹是在我的帐户中创建的,但文件没有上传到 Dropbox。这是我的代码:

public void exportDataInCSV(final String file_name,
            final ArrayList<Assessment> assessments, final boolean dropBox)
            throws IOException {

        final File folder = new File(Environment.getExternalStorageDirectory()
                + "/MYDIR");

        boolean var = false;
        if (!folder.exists())
            var = folder.mkdir();

        System.out.println("" + var);

        final String filename = folder.toString() + "/" + file_name + ".csv";

        // show waiting screen
        CharSequence contentTitle = getString(R.string.app_name);

        final ProgressDialog progDailog = ProgressDialog.show(DataExport.this,
                contentTitle, "Exporting data...", true);// please
                                                            // wait

        new Thread() {
            public void run() {
                try {

                    FileWriter fw = new FileWriter(filename);

                    fw.append("MYNAME");
                    fw.append(',');

                    fw.append("MYSIRNAME");

                    fw.close();
                    if (dropBox) {

                        File file = new File(folder.toString() + "/"
                                + file_name + ".csv");
                        FileInputStream inputStream = new FileInputStream(file);
                        Entry response = mDBApi.putFile("/magnum-opus.txt",
                                inputStream, file.length(), null, null);

                    }
                } catch (Exception e) {
                }
                progDailog.dismiss();
            }
        }.start();

    }

所以有人可以帮助我并告诉我如何将我使用文件编写器创建的文件上传到 Dropbox,该文件也保存到手机的 SD 卡中。

4

0 回答 0