}
private void downloadDictionary(final String downloadUrl, long bytes, Button downloadButton) {
- String fileName;
+ String destFile;
try {
- fileName = new URL(downloadUrl).getFile();
+ destFile = new File(new URL(downloadUrl).getPath()).getName();
} catch (MalformedURLException e) {
throw new RuntimeException("Invalid download URL!", e);
}
while (cursor.moveToNext()) {
if (downloadUrl.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI))))
break;
- if (fileName.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_TITLE))))
+ if (destFile.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_TITLE))))
break;
}
if (!cursor.isAfterLast()) {
Request request = new Request(
Uri.parse(downloadUrl));
- final String destFile = new File(fileName)
- .getName();
Log.d(LOG, "Downloading to: " + destFile);
- request.setTitle(fileName);
+ request.setTitle(destFile);
try {
request.setDestinationInExternalFilesDir(getApplicationContext(), null, destFile);