java - only the first file gets downloaded -


i have string array , want both files downloaded, reason it's first element of array gets downloaded. first element downloaded dropbox correctly need second 1 later. better if call preworks() function oncreate twice? can problem?

thanks

public void preworks() {     asynctask = new asynctask<void, void, void>() {          @override         protected void doinbackground(void... params) {              int count = 0;             string[] txt_files = {"/l12.txt", "/l13.txt"};              (string filename : txt_files) {                  file file = new file(environment.getexternalstoragedirectory()                         .getabsolutepath() + "/do" + filename);                  string response = "";                  if (!(file.exists())) {                     //file doesn't exist!!                      androidauthsession session = null;                     try {                         session = buildsession();                     } catch (dropboxexception e) {                         e.printstacktrace();                     }                     dropboxapi = new dropboxapi<>(session);                       dir.mkdirs();                      file filedb = new file(file + filename                             .substring(filename.lastindexof('.')));                     try {                         fileoutputstream outputstream = new fileoutputstream(filedb);                         textdownloader.dropboxapi.getfile(filename, null,                                 outputstream, null);                         return null;                     } catch (filenotfoundexception e) {                         e.printstacktrace();                     } catch (dropboxexception e) {                         e.printstacktrace();                     }                 }                  bufferedreader br;                  try {                     br = new bufferedreader(new inputstreamreader(new                             fileinputstream                             (file), "cp1252"));                     (string line; (line = br.readline()) != null;                          response += line + '\n');                      count = response.length() - response.replace(";", "").length();                  } catch (filenotfoundexception e) {                  } catch (ioexception e) {                  }                  string prefilename = filename.substring(0, filename.length() - 4);                  preferencemanager.getdefaultsharedpreferences(textdownloader.this)                         .edit()                         .putstring(prefilename, response).apply();              }             return null;         }          @override         protected void onpostexecute(void param) {             toast.maketext(textdownloader.this, "your file has been downloaded", toast                     .length_short)                     .show();             intent intent = new intent(textdownloader.this, mainactivity.class);             textdownloader.this.startactivity(intent);          }           @override         protected void onpreexecute() {             super.onpreexecute();             //tv1.settext("your file getting downloaded");             toast.maketext(textdownloader.this, "your file getting downloaded", toast.length_short)                     .show();         }      };      asynctask.execute();  } 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -