Code example for DownloadManager

Methods: queryremove

0
            DownloadManager.Query q = new DownloadManager.Query();
            q.setFilterById(id);
 
            int reason = 0;
 
            Cursor c = dm.query(q);
            if (c != null && c.moveToFirst()) {
                if (c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_FAILED) {
                    reason = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
                    String uri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_URI));
                    dm.remove(id);
 
                    String title = c.getString(c.getColumnIndex(DownloadManager.COLUMN_TITLE));
 
                    title = title.replaceAll("[^a-zA-Z0-9]+", "");
 
//                    Intent downloadIntent = new Intent(context, DownloadService.class); 
//                    downloadIntent.putExtra(DownloadService.URL, uri); 
//                    downloadIntent.putExtra(DownloadService.ID, id); 
//                    downloadIntent.putExtra(DownloadService.TITLE, title); 
Connect your IDE to all the code out there  Get Codota for Java