I am currently working on android project and trying to enable DropBox functionality. I've selected the access type to App Only, and I can successfully authenticate and it creates an Apps directory and inside that creates a directory with the name of my app.
When I then try to put a file in the DropBox directory it goes into the DropBoxException catch and in the logcat prints com.dropbox.client2.exception.DropboxUnlinkedException.
I've done a google and from what I've seen this happens if the apps directory has been deleted and so authentication is required to be re-done, but this isn't the case, I have deleted it and I am putting the file straight after doing the authentication.
Below is the code that retrieves the keys and stores the file on dropbox.
AccessTokenPair tokens = getTokens();
UploadFile uploadFile = new UploadFile(context, common, this, mDBApi);
uploadFile.execute(mDBApi);
Below is the code for the getTokens method (don't think this would help but you never know)
private AccessTokenPair getTokens()
{
AccessTokenPair tokens;
SharedPreferences prefs = context.getSharedPreferences("prefs", 0);
String key = prefs.getString("dropbox_key", "");
String secret = prefs.getString("dropbox_secret", "");
tokens = new AccessTokenPair(key, secret);
return tokens;
}
Below is the class that extends the AsyncTask to perform the upload
class UploadFile extends AsyncTask<DropboxAPI<AndroidAuthSession>, Void, bool>
{
Context context;
Common common;
Synchronisation sync;
DropboxAPI<AndroidAuthSession> mDBApi;
public UploadFile(Context context, Common common, Synchronisation sync,
DropboxAPI<AndroidAuthSession> mDBApi)
{
this.context = context;
this.common = common;
this.sync = sync;
this.mDBApi = mDBApi;
}
@Override
protected bool doInBackground(DropboxAPI<AndroidAuthSession>... params) {
try
{
File file = new File(Environment.getExternalStorageDirectory() + "/BoardiesPasswordManager/dropbox_sync.xml");
FileInputStream inputStream = new FileInputStream(file);
Entry newEntry = mDBApi.putFile("android_sync.xml", inputStream, file.length(), null, null);
common.showToastMessage("Successfully uploade Rev: " + newEntry.rev, Toast.LENGTH_LONG);
}
catch (IOException ex)
{
Log.e("DropBoxError", ex.toString());
} catch (DropboxException e) {
Log.e("DropBoxError", e.toString());
e.printStackTrace();
}
return null;
}
I have no idea why it would display the UnlinkedException so any help would be greatly appreciated.