How Can I Make Download Manager Overwrite An Exisiting File Instead Of Renaming The File In Android
I have a database file which is on the sdcard and now when a new database file is downloaded i need it to overwrite the old one instead of renaming it here is my downloading code.
Solution 1:
when you're submitting the file to the download manager check if the file already exists. then delete it.
private boolean isFileExists(String filename){
File folder1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + filename);
return folder1.exists();
}
private boolean deleteFile( String filename){
File folder1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + filename);
return folder1.delete();
}
Post a Comment for "How Can I Make Download Manager Overwrite An Exisiting File Instead Of Renaming The File In Android"