java - 检查 dir 存在和 dir contains 在 dropbox api 上不起作用

标签 java android dropbox dropbox-api

DBRoulette.java

private final String DATA_DIR = "/DataBase/";   

Dropbox

下载随机图片

 public DownloadRandomPicture(Context context, DropboxAPI<?> api,
            String dropboxPath, ImageView view) {
    mPath = dropboxPath;

doInBackground()

Entry dirent = mApi.metadata(mPath, 1000, null, true, null);
 if (!dirent.isDir || dirent.contents == null) {
                    // It's not a directory, or there's nothing in it
                    mErrorMsg = "File or empty directory";
                    return false;
                }

此代码在 DownloadRandomPicture.java 上不起作用 有人知道如何解决吗?

最佳答案

如果我们使用

final static private AccessType ACCESS_TYPE = AccessType.DROPBOX;

我们应该

Entry dirent = mApi.metadata(mPath, 1000, null, false, null);

但是如果我们使用

final static private AccessType ACCESS_TYPE = AccessType.APP_FOLDER;

我们应该使用

Entry dirent = mApi.metadata(mPath, 1000, null, true, null);     

差异在于 dirent 的 boolean 值

关于java - 检查 dir 存在和 dir contains 在 dropbox api 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11931257/

相关文章:

windows - 尝试通过 Windows 上的 Alias 向 Apache on Dropbox 文件夹授予权限

java - Jolt 变换未命名数组

java - 获取数据库信息到Android中的另一个类

android - 如何防止某些功能被剥离?

php - 使用 Dropbox 的 v2 API 将文件上传到 Dropbox

java - 解析 DBXException java 的最佳方法

java - SpannableString.setSpan() 第二个参数是基于 0 的吗?

java - SQL子查询没有返回任何值,但junit测试仍然通过

java - SE 应用程序的 JPA persistence.xml 数据源

android - 系统UI(Statusbar和Navigation Bar)渲染神器