Cannot upload file to dropbox
I'm having trouble uploading file to Dropbox. I do not get any errors, the
app folder is created in my account, but the file is not uploaded to
dropbox. Here is my code:
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();
}
So can someone help me and tell me how can I upload the file i'm creating
using the filewriter to Dropbox, that is also saved to the phone's SD
card.
No comments:
Post a Comment