Aspsine / MultiThreadDownload

Android Multi-Thread Download library
908 stars 285 forks source link

Delete file and remove thread from database #72

Closed sajadmartiny closed 8 years ago

sajadmartiny commented 8 years ago

hi , how to remove one thread from database when file not downloading full , and adding again not downloading continuation

Aspsine commented 8 years ago

You want to not resuming the download when you start download with the same tag again?

if(DownloadManager.getInstance().isRunning(tag)){
    // has callback
    DownloadManager.getInstance().cancel(tag);
}else{
    // no callback
    DownloadManager.getInstance().delete(tag);
}

I made some changes last night and fixed some bugs. Make sure to use the latest version.

sajadmartiny commented 8 years ago

i want delete my file and thread from database when my download pause

public void delete(String tag) {
        DownloadInfo downloadInfo = getDownloadInfo(tag);
        if (downloadInfo != null) {
            File file = new File(downloadInfo.getDir(), downloadInfo.getName());
            if (file.exists() && file.isFile()) {
                file.delete();
            }
        }
        mDBManager.delete(tag);
    }

return exception because downloadInfo.getName return null
and i test delete from thread database with tag but do not work and thread didn't delete from table

Aspsine commented 8 years ago
final DownloadRequest request = new DownloadRequest.Builder()
            .setName(appInfo.getName() + ".apk")
            .setUri(appInfo.getUrl())
            .setFolder(mDownloadDir)
            .build();

Did you setName(...)?

sajadmartiny commented 8 years ago

yes i set name but i am fix it whit public void delete(String tag) { String key = createKey(tag); mDBManager.delete(key); } if not delete from data base when re downloading file , could not open file because damaged and Thanks you for library