Check whether file exists

In the current app I’m developing user has privileged┬áto add an image to the application. Image Uri (sd card location) will be saved in SQLite. Now the problem arises what if the user deletes the image in SD card and app trying to access it.┬áDefinitely┬áthat’ll be a force close. This is how we can check whether file exist or not before calling the image.

private Uri imgurl ="sdcard/1.jpg"; file = new;
if (file.exists()) {
do your stuff here
Did you enjoy this article?
Signup today and receive free updates straight in your inbox. We will never share or sell your email address.

1 Comment

  1. Sir/mam
    Now a days I can’t download for applications y any problem for downloading


Leave a Reply