htafoya
htafoya

Reputation: 19273

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.

Upvotes: 1

Views: 2221

Answers (1)

mmlooloo
mmlooloo

Reputation: 18977

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.

Upvotes: 4

Related Questions