I'm using the following code to get the total number of files present at root level in a folder for Dropbox:
public int getFilesCount(@NonNull final String inPath) throws DbxException {
Log.i(LOGGER, "Getting files count for: " + inPath);
ListFolderResult result = mClient.files().listFolder(inPath);
return result.getEntries().size();
}
This code works correctly!
But looks like this code first get the list of all files present under the folder and then gets the count. This takes a significant network time. Is there any faster way to just get the total number of files instead of iterating over the directory?
Using Dropbox version 3.0.3
There isn't a way to retrieve the file count without listing everything and counting unfortunately. We'll consider it a feature request.
Also, note that the listFolder
interface is paginated, so you aren't guaranteed to get everything in a single call to listFolder
. You may need to additionally call listFolderContinue
. You can find more information in the listFolder
documentation: