Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I have to admit here that I'm both new to Android and new to the DropBox API (but not new to development) so maybe I'm doing something wrong but I cannot get listFolder to return any files no matter what I try.
My code is below and the loop that gets the files is taken from the example API code. There is no issue conencting with the API but no matter what path I put in I either get nothing (if I use "") or an exception if use any other path.
One other thing I'm also confused about - once I've set up an app in the DropBox dashboard (say it's called MyTestApp) do I then need to create a folder of the same name in the root of my DropBox folder? If not, where is the folder for the app to be found? I am assuming using "" as the path is the same as saying DropBox/MyTestApp. I have 5 files of mixed type in this folder but the code never returns anything.... can anyone help me out to get this working?
public class MainActivity extends AppCompatActivity {
private List<TestClass> filesList;
final static private String APP_KEY = "yyyyyyyyyyyy";
final static private String ACCESS_TOKEN = "xxxxxxxxxxx";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//I KNOW THIS IS NOT GOOD CODE BUT I JUST WANT TO GET THE listFolder WORKING
//BEFORE MAKING A SEPERATE FUNCTION FOR THIS.
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
DropboxClientFactory dbFactory = new DropboxClientFactory(ACCESS_TOKEN);
DbxClientV2 client = dbFactory.getClient();
//TestClass is just a simlpe class with an integer and a string
filesList = new ArrayList<TestClass>();
try {
ListFolderResult result = client.files().listFolder("");
while (true) {
for (Metadata metadata : result.getEntries()) {
System.out.println(metadata.getPathLower()); //Never prints anything
filesList.add(new TestClass(metadata.getPathLower()));
}
if (!result.getHasMore()) {
break;
}
result = client.files().listFolderContinue(result.getCursor());
}
}
catch (DbxException ex)
{
System.out.println("EXCEPTION getting DropBox Files list: " + ex.getMessage());
}
}
}
Hi Greg, many thanks for the answer.
I already had an Apps folder in my DropBox (created by me a while back for another purpose) and when I add a new app to the dashboard the app folder is not being created within Apps - could the fact that I created the Apps folder myself be the issue?
Since the dashboard didn't create the appropriate app folder I went ahead and created it myself (e.g: Apps/MyTestApp1) and copied files to it but still nothing is picked up.
Perhaps I should I delete my Apps folder, delete the app from my dashboard and start again?
Alternatively, is there an API call that I can use to find what DropBox thinks the default folder is? (I'll look up the API docs as well of course)
Finally, just so I'm really clear, can you confirm that if I go into my dashboard and create a new app, say MyTestApp2, then when I refresh my DropBox there should a MyTestApp2 folder inside the Apps folder? I'm just concerned I'm missing some really fundamental step that may be obvious to experienced DropBoxAPI users but perhaps not to first-timers like me. I was unable to find an Android app example from scratch so I'm just using scraps of knowledge from all over the place.
Hi Greg, sorry it's taken a while to reply, have been away for a few days.
I think the issue was something to do with me having already created the Apps folder well before I started my Android app - rather than using Windows Explorer (which was showing the files in the Apps/<appname> folder when I went to Dropbox.com I could see they had not been synched. When I tried to do that I got a synching error in Explorer and it showed two Apps folders, one with an error next to it. I deleted the one I created manually and moved some test files to the <appname> folder and re-ran my app and now it does return the files in the Apps/<appname> folder.
Many thanks for your help 🙂
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!