0

Why are my codes not working its way copy a file from a directory to another after being initialized? Where it does not seems to even loop into the copyFile class method? Is it because i have not given it time to copy/transfer the file or have i done something wrong in my codes?

I'm rather new in android/programming can someone help?

Alertdialog onClick function to call upon the copyFile method.

Vivian
  • 1,071
  • 5
  • 16
  • 29

1 Answers1

0

It looks like you are trying to write to the archive directory itself, instead of to a new file inside that directory.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • Inside `copyFile`, after you ensure that `destFile` points to a directory that actually exists, I think it may be enough to create a File that points to the actual output file desired: `destFile = new File(destFile, sourceFile.getName());` – Ted Hopp May 19 '11 at 03:04
  • @Ted Hopp i have updated my code above is it this way? Sorry if i'm wrong i'm rather new in android/java.. – Vivian May 19 '11 at 03:15
  • @Ted Hopp or i need the progress bar during transfer because when i return to the folder i don't seems to see the file? After after a while it reappear... – Vivian May 19 '11 at 03:19
  • @Vivian - Your updated code creates the File object pointing to the desired file, but you appear to have deleted all the code that does the transfer! I had meant that after ensuring that the destination directory exists, you should redefine `destFile` to point to a new file _and then proceed with the rest of the method as it was_. – Ted Hopp May 19 '11 at 03:24
  • @Vivian - As to the progress bar not appearing, you will need to move the entire file copying process to an [AsyncTask](http://developer.android.com/reference/android/os/AsyncTask.html) to allow the UI to continue operating. – Ted Hopp May 19 '11 at 03:26
  • @Ted Hopp which means i have create a new java file to handle AsyncTask or it still stays at the same java file? – Vivian May 19 '11 at 03:45
  • @Ted Hopp for my case how should i use AsyncTask to update my progress bar, i saw a similar example here but i don't know how to implement it in my own context? --> http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog can you help me with this? – Vivian May 19 '11 at 03:59
  • @Vivian - it's a little hard to answer an entirely new question using comments. It would be best if you start a new question, posting the code you have now and explaining where you need help. – Ted Hopp May 19 '11 at 17:46
  • @Ted Hopp i've try it out for the AsyncTask but it happen to arouse another problem for not updating my listview entry content whyis it so? --> http://stackoverflow.com/questions/6060982/why-is-the-content-of-my-listview-entries-not-updated-after-the-transfer-of-file – Vivian May 20 '11 at 01:48