Trying to show toast if file already exist into SDCard, but seems condition not works for me
public void startDownload(View v) {
if(hasAudio.equals("no"))
{
Toast.makeText(getApplicationContext(), "MP3 not Available !", Toast.LENGTH_LONG).show();
}
else if(hasAudio.equals("yes"))
{
File file = new File(getExternalCacheDir() + "Audios", title + ".mp3" );
if (file.exists())
{
Toast.makeText(getApplicationContext(), "Already downloaded !", Toast.LENGTH_LONG).show();
}
else
{
Uri uri=Uri.parse(download);
mgr.enqueue(new DownloadManager.Request(uri)
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |
DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
.setTitle(title)
.setDestinationInExternalPublicDir("Audios", title + ".mp3"));
v.setEnabled(false);
}
}
}
whenever i do tap on button, its start downloading mp3, no matter already exist or not, but i want to show the toast if file already exist in SD Card