java - How to check whether a file already exists in Dropbox -


i using following code upload file dropbox. want check if file exists on dropbox already, avoid duplications. how can check if file exists or not? new android, don't know now

public class uploadfiletodropbox extends asynctask<void, void, boolean> {      private dropboxapi<?> dropbox;     private string path;     private context context;      public uploadfiletodropbox(context context, dropboxapi<?> dropbox,                                string path) {         this.context = context.getapplicationcontext();         this.dropbox = dropbox;         this.path = path;     }      @override     protected boolean doinbackground(void... params) {         final file tempdir = context.getcachedir();         file tempfile;         filewriter fr;         try {             tempfile = file.createtempfile("file", ".txt", tempdir);             fr = new filewriter(tempfile);             fr.write("test file uploaded using dropbox api android");             fr.close();              fileinputstream fileinputstream = new fileinputstream(tempfile);             dropbox.putfile(path + "sample.txt", fileinputstream,                     tempfile.length(), null, null);             tempfile.delete();             return true;         } catch (ioexception e) {             e.printstacktrace();         } catch (dropboxexception e) {             e.printstacktrace();         }         return false;     }      @override     protected void onpostexecute(boolean result) {         if (result) {             toast.maketext(context, "file uploaded successfully!",                     toast.length_long).show();         } else {             toast.maketext(context, "failed upload file", toast.length_long)                     .show();         }     } } 

private void loadfiles(final string directory) {         new thread() {             @override             public void run() {                  string mpath = directory;                 entry direntex = null;                 try {                     direntex = mapi.metadata(mpath, 1000, null, true, null);                 } catch (dropboxexception e) {                     e.printstacktrace();                 }                  if (direntex.contents.size() != 0) {                     (entry ent : direntex.contents) {                         string name = ent.filename();                           /*compare file here*/                     }                  }                  super.run();             }          }.start();      } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -