Search code examples
javaandroiddropboxdropbox-api

Checking dir exist and dir contain won't work on dropbox api


DBRoulette.java

private final String DATA_DIR = "/DataBase/";   

Dropbox

DownloadRandomPicture

 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;
                }

this code is not working at DownloadRandomPicture.java anyone know how to fix it?


Solution

  • If we are using

    final static private AccessType ACCESS_TYPE = AccessType.DROPBOX;
    

    we should

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

    but if we are using

    final static private AccessType ACCESS_TYPE = AccessType.APP_FOLDER;
    

    we should use

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

    The difference is at the boolean at the dirent