I am trying to retrieve the tag of the Metadata of Dropbox so that i can save it in a List and use it to display if the given Data is of Type File,Folder or was it deleted ?
This is the method I am using withIncludedDeleted which allows me to display all the deleted File/Folder with the non deleted ones with the showing Tag if it is deleted or not.
ListFolderBuilder EntrylistFolderBuilder = getDbxCleint().files().listFolderBuilder("/data/entries");
ListFolderResult result = EntrylistFolderBuilder.withRecursive(true).withIncludeDeleted(true).start();
while (true) {
for (Metadata metadata : result.getEntries()) {
mEntries.add(metadata);
//--------//
}
if (!result.getHasMore()) {
break;
}
result = getDbxCleint().files().listFolderContinue(result.getCursor());
}
}
Is it possible to just retrieve the Tag from Metadata ? because I don't want to write do different very similar looking methods one with Include Delete and other without it just two print two lists.
This is how the Metadata stored in mEntries ArrayList looks like-
{".tag":"folder","name":"entries","id":"id:NNgoZ4mypJAAAAAAAAABCw","path_lower":"/data/entries","path_display":"/data/entries"}
{".tag":"deleted","name":"entry_87e7c498a6631825dd3aa5a3c810c49a","path_lower":"/data/entries/entry_87e7c498a6631825dd3aa5a3c810c49a","path_display":"/data/entries/entry_87e7c498a6631825dd3aa5a3c810c49a"}
{".tag":"file","name":"entry_0d08beeee44681783e76de22fdfa9cb1","id":"id:NNgoZ4mypJAAAAAAAAAA_g","client_modified":"2019-03-04T10:11:44Z","server_modified":"2019-03-04T10:11:45Z","rev":"017000000012d1542b0","size":389,"path_lower":"/data/entries/entry_0d08beeee44681783e76de22fdfa9cb1","path_display":"/data/entries/entry_0d08beeee44681783e76de22fdfa9cb1","content_hash":"b05a1ceebccebd2d85520b944b56ddb7edefc7823a129a9bc116d60bbc9227a7"}
{".tag":"file","name":"entry_48b6afc3a21d255ef0cbe3ec758be441","id":"id:NNgoZ4mypJAAAAAAAAAA_w","client_modified":"2019-03-04T10:11:44Z","server_modified":"2019-03-04T10:11:45Z","rev":"018000000012d1542b0","size":2010,"path_lower":"/data/entries/entry_48b6afc3a21d255ef0cbe3ec758be441","path_display":"/data/entries/entry_48b6afc3a21d255ef0cbe3ec758be441","content_hash":"5c94187209c748e22a38926fddbbf860460e14fee1f3d76f9e81aefc446a6612"}
When using the Dropbox SDK as you are, you don't need to interact with the JSON directly (e.g., to get the '.tag.' value). The SDK translates these objects into native typed objects for you. You can check the type of the objects to handle them as desired. You can check the type using instanceof
.
There's an example of using it here. In your case, in addition to checking if it's a FileMetadata
or FolderMetadata
, you can check if it's a DeletedMetadata
. (All three of these are subclasses of Metadata
.)