0

DBRoulette.java

private final String DATA_DIR = "/DataBase/";   

投递箱

下载随机图片

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

做背景()

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 任何人知道如何修复它?

4

2 回答 2

1

如果我们使用

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 的布尔值

于 2012-08-13T09:29:53.103 回答
1

试试这个,它对你有用...

 try 
    {
        Entry existingEntry = mApi.metadata("/" + SavedProperties.selectedAddress , 1, null, false, null);
        if(existingEntry.isDir)
        {
            Log.d(TAG, "Folder exists : " + existingEntry.fileName());
            uploadPictures("/"+SavedProperties.selectedAddress + "/");
        }
    } 
    catch (DropboxException  e) 
    {
        Log.d(TAG,"Folder does not exist..." + e.fillInStackTrace());
        try 
        {
            Entry createFolder = mApi.createFolder("/"+SavedProperties.selectedAddress);
            Log.d(TAG,"Folder created..." + createFolder.rev);
            uploadPictures("/"+SavedProperties.selectedAddress + "/");
        } 
        catch (DropboxException e1)
        {
             Log.d(TAG,"Create Folder DropboxException : " + e1.fillInStackTrace() );
        }       
    }
于 2014-03-31T10:20:57.997 回答