cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AndroidAuthSession, DropboxException are not recognizable

AndroidAuthSession, DropboxException are not recognizable

rekte
Explorer | Level 3

Hello, I deleted the v1 dropbox sdk from my android app and added 3.0.4. The following things are not recognizable by android studio. Where can I check out what to use intead of (for example) AndroidAuthSession?

 

Thanks

AndroidAuthSession,
DropboxException
DropboxAPI

 

private AndroidAuthSession buildSession() throws DropboxException {
AppKeyPair appKeyPair = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeyPair);

session.setOAuth2AccessToken(ACCESSTOKEN);
return session;
}
AndroidAuthSession session = null;
try {
session = buildSession();
} catch (DropboxException e) {
e.printStackTrace();
}
dropboxAPI = new DropboxAPI<>(session);
String[] fnames;
DropboxAPI.Entry dirent = null;
try {
dirent = dropboxAPI. metadata("/", 1000, null, true, null);
} catch (DropboxException e) {
e.printStackTrace();
}
ArrayList<DropboxAPI.Entry> files = new ArrayList<>();

 

1 Reply 1

Greg-DB
Dropbox Staff

For Android, we recommend using the official Dropbox API v2 Java SDK:

 

https://github.com/dropbox/dropbox-sdk-java

 

It sounds like you've already installed that. It doesn't use the same classes/interface as the old version, so you'll need to update your code. There's an example Android app using it here:

 

https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android

 

For instance, your AndroidManifest.xml should be set up as shown here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/AndroidManifest.xm...

 

You start the flow by calling startOAuth2Authentication as shown here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

You complete the flow by calling getOAuth2Token as shown here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

Your app can store and re-use the resulting access token for that user, as the example does here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

You can find examples of calling getMetadata and listFolder here:

 

https://github.com/dropbox/dropbox-sdk-java/blob/e707252998d14821b06e7e2a2b69a9c80d7b0829/examples/w...


https://github.com/dropbox/dropbox-sdk-java/blob/c6aeb4bf3011e6b803eaa325ea20a52f8412ee0f/examples/t...

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?