I have downloaded and installed the Dropbox Sync API for Android from here: https://www.dropbox.com/developers/sync
I couldn't understand much of their tutorial. It lacked a lot of crucial variables, so that I had to find them out myself. I now have a very messy code and a lot of things aren't there.
private DbxAccountManager mDbxAcctMgr;
static final int REQUEST_LINK_TO_DBX = 0; // This value is up to you // thanks for telling what it actually does, Dropbox!
DbxPath path = new DbxPath("/test.pdf");
public void onClickLinkToDropbox(View view) {
mDbxAcctMgr.startLink((Activity)this, REQUEST_LINK_TO_DBX);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_LINK_TO_DBX) {
if (resultCode == Activity.RESULT_OK) {
DbxFileSystem dbxFs = DbxFileSystem.forAccount(mDbxAcctMgr.getLinkedAccount()); // try /catch error
DbxFile testFile = dbxFs.open(path); //try/catch error
String contents = testFile.readString();
Log.d("Dropbox Test", "File contents: " + contents); // try / catch error
} else {
// ... Link failed or was cancelled by the user.
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
This gives me errors on the 3 lines, saying that I need to add try/catch. But when I add try/catch, Eclipse tells me to null the variables, which would mean all the functions would only read nulls, thus not reading anything..
Could anyone help me any further? Dropbox only confused me more by giving wrong instructions etc. I am sure that even if I didn't have 3 try/catch errors it would still not work.
Anyone here who has experience with the Dropbox Sync API and could share an example program reading a txt file in a User's Dropbox folder?
Bart