2015-12-02 23 views
1

我試圖在Dropbox上使用DbxClientV2實現「跟上對文件和文件夾的更改」。我能夠構建以下內容: TreeMap children = new TreeMap(); Files.ListFolderResult結果;從Dropbox 2.0 API使用Files.listFolder跟上文件夾中文件的更改

String cursor = null; 

    while (true) { 
     result = client.files.listFolder("/MyDirectory/Reports"); 
     if (!result.cursor.equals(cursor)) { 
      cursor = result.cursor; 
      for (Metadata md : result.entries) { 
       if (md instanceof DeletedMetadata) { 
        children.remove(md.pathLower); 
       } else { 
        children.put(md.pathLower, md); 
       } 
      } 
     } 
     if (!result.hasMore) { 
      try { 
       Thread.sleep(1000); 
      } catch (InterruptedException ex) { 

      } 
     } 
    } 

我的問題是:我怎麼能retrive「/ mydirectory中/報表」文件夾中的光標從Dropbox的服務器檢查自己是否應該更新我的本地庫「孩子」?

回答

0

我真的不明白你問的問題,所以我不知道這是否回答,但你的代碼似乎並沒有實際使用光標。我想你想要更類似這樣的東西:

while (true) { 
    if (cursor == null) { 
     result = client.files.listFolder("/MyDirectory/Reports"); 
    } else { 
     result = client.files.listFolderContinue(cursor); 
    } 
    cursor = result.cursor; 
    for (Metadata md : result.entries) { 
     ... 

如果這樣做沒有幫助,可否請您重新解釋一下您的問題?

+0

它完美的作品!感謝您的回覆! – michal

相關問題