Code example for DownloadManager

Methods: query, openDownloadedFile

0
		public void onReceive(Context arg0, Intent arg1) { 
			// TODO Auto-generated method stub 
			DownloadManager.Query query = new DownloadManager.Query(); 
			query.setFilterById(preferenceManager.getLong(strPref_Download_ID, 
					0)); 
			Cursor cursor = downloadManager.query(query); 
			if (cursor.moveToFirst()) { 
				int columnIndex = cursor 
						.getColumnIndex(DownloadManager.COLUMN_STATUS); 
				int status = cursor.getInt(columnIndex); 
				if (status == DownloadManager.STATUS_SUCCESSFUL) { 
 
					// Retrieve the saved request id 
					long downloadID = preferenceManager.getLong( 
							strPref_Download_ID, 0); 
 
					ParcelFileDescriptor file; 
					try { 
						file = downloadManager.openDownloadedFile(downloadID); 
						FileInputStream fileInputStream = new ParcelFileDescriptor.AutoCloseInputStream( 
								file); 
						Bitmap bm = BitmapFactory.decodeStream(fileInputStream); 
						image.setImageBitmap(bm); 
					} catch (FileNotFoundException e) {