我想使用它的Android API列出来自Dropbox的目录内容的内容。我尝试在for循环中使用dirEntry.contents() ,如下所示:
Entry rootDirEnt = mApi.metadata(mPath, 1000, null,
true, null);
if (!rootDirEnt.isDir || rootDirEnt.contents == null) {
// It's not a directory, or there's nothing in it
mErrorMsg = "No files available in Dropbox";
return false;
}
for (Entry childDirEnt : rootDirEnt.contents) {
// check if it still exists
if (childDirEnt.isDir && !childDirEnt.isDeleted
&& childDirEnt.contents != null) {
// childDirEnt contents is already null, even though there are files inside this directory
for (Entry fileEnt : childDirEnt.contents) {
// do smth with file
if (isCancelled()) {
return false;
} else {
publishProgress();
}
}
}
}
因此,我再次想到了使用新路径的 usign mApi.metadata() ,但我的问题是:如果不为根目录中的每个目录调用 medata() ,我不能这样做吗?(也许使用内容调用或smth ..)