0

I am downloading an Android application to the path: /mnt/sdcard/download/App.apk using the DownloadManager class. If the App.apk already exists, the download fails. How to replace the existing apk?

user1471575
  • 731
  • 2
  • 15
  • 23

1 Answers1

3

DownloadManager will not let you do this. You should delete or rename the existing file first.

File f = new File("/mnt/sdcard/download/App.apk");
if (f.exists()) { 
    f.delete();
    // or
    f.renameTo(...);
}
Graham Borland
  • 60,055
  • 21
  • 138
  • 179