简体   繁体   中英

Android - DownloadManager replace file with the same path

Is it possible to replace the downloaded file if it has the same name?

Right now the DM is creating file a.txt, and then a-1.txt and so on. Sometimes I will need to update the downloaded file.

The only way that I see seems to be to check and delete the file before the download begins, but this will leave the application without file while the file is being downloaded.

Is it possible to replace the downloaded file if it has the same name?

No because of:

public static final int ERROR_FILE_ALREADY_EXISTS

The only way that I see seems to be to check and delete the file before the download begins, but this will leave the application without file while the file is being downloaded.

move your file to a temp folder and set download manager destination to original folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM