I am developing an application which will get last modified time and date for the file on Dropbox and also it will get the last modified date(upload time of file) and time of file on local machine and then after comaparing both the time and date the application will decide whether to upload that file or download it from dropbox. Now I am stuck with this question, that how can I get last modified date & time of particular file on dropbox.
2 Answers
Answered a second ago on the Dropbox dev forum: https://forums.dropbox.com/topic.php?id=109662.
But pasted here for posterity:
It's part of the metadata for a file: https://www.dropbox.com/developers/core/docs#metadata
1 Comment
Jan
the first two links give 0x404, unfortunately
private void GetServerModifiedTime(String my_token, String my_path_to_root_folder) throws IOException
{
//create the new DropBox client
DbxClientV2 my_dropbox_client = new DbxClientV2(new DbxRequestConfig("my_app_name_and_version"), my_token);
List<Metadata> list_of_metadata_for_all_files = new ArrayList<Metadata>();
try {
//get a list of all files
list_of_metadata_for_all_files = my_dropbox_client.files().listFolder(my_path_to_root_folder).getEntries();
for (Metadata file_metadata : list_of_metadata_for_all_files)
{
if (!(file_metadata instanceof FolderMetadata)) {
String file_name = file_metadata.getName();
String root_path_plus_file_name = my_path_to_root_folder + "/" + file_name;
FileMetadata file_meta_data = (FileMetadata) my_dropbox_client.files().getMetadata(root_path_plus_file_name);
Date file_date = file_meta_data.getServerModified();
long file_server_modified = file_date.getTime();
Log.i("", "-------->" + file_server_modified + "\n");
}
}
}catch (DbxException ignore){
throw new IOException(ignore);
}
}