Hi everybody, I'm new to dropbox developing and I need help with it please. I wrote an android application that needs to get a list of files listing in dropbox. I used the tutorial and part of the code I wrote is:
private DropboxAPI<AndroidAuthSession> mDBApi;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
InitializeSession();
}
void InitializeSession()
{
AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeys);
mDBApi = new DropboxAPI<AndroidAuthSession>(session);
mDBApi.getSession().startOAuth2Authentication(MainActivity.this);
}
@Override
protected void onResume()
{
super.onResume();
if (mDBApi.getSession().authenticationSuccessful())
{
try
{
mDBApi.getSession().finishAuthentication();
String accessToken = mDBApi.getSession().getOAuth2AccessToken();
PopulateList();
}
catch (IllegalStateException e)
{
System.out.println("Error : " + e.getMessage());
}
}
}
private void PopulateList()
{
List<String> filename = new ArrayList<>();
String mPath = "/";
DropboxAPI.Entry dirent = null;
try
{
dirent = mDBApi.metadata(mPath, 1000, null, true, null);
}
catch (DropboxException e)
{
System.out.println("Error : " + e.getMessage());
}
for (DropboxAPI.Entry ent : dirent.contents)
{
if (ent.isDir)
{
filename.add(ent.fileName());
}
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, filename);
}
}
I am not getting the list of files from dropbox...
In the PopulateList() method, after executing the line
dirent = mDBApi.metadata(mPath, 1000, null, true, null);
The code stop executing and I get nothing to the dirent.
What am I doing wrong here? and what am I missing?
Do I somehow need to resume the authentication again?
One more thing I'm not sure about, with this code do I get files from sub folders too? if not, how can I get them? because the start path I use is "/".
I'm stuck on that for 2 weeks and can't find the solution or what did I do wrong...
Thanks for the helpers! 