Code example for DownloadManager

Methods: queryremove

0
        }    
    };    
    private void queryDownloadStatus() {    
        DownloadManager.Query query = new DownloadManager.Query();   
        query.setFilterById(dmId);   
        Cursor c = downloadManager.query(query);   
        if(c.moveToFirst()) {   
            int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));   
            switch(status) {   
            case DownloadManager.STATUS_PAUSED:   
                Log.v("down", "STATUS_PAUSED");  
            case DownloadManager.STATUS_PENDING:   
                Log.v("down", "STATUS_PENDING");  
            case DownloadManager.STATUS_RUNNING:   
                //正在下载,不做任何事情   
                Log.v("down", "STATUS_RUNNING");  
                break;    
            case DownloadManager.STATUS_SUCCESSFUL:   
                //完成   
                Log.v("down", "下载完成");  
                
                break;    
            case DownloadManager.STATUS_FAILED:   
                //清除已下载的内容,重新下载   
                Log.v("down", "STATUS_FAILED");  
                downloadManager.remove(dmId);   
                   
                break;    
            }    
        }   
    }