0

In android studio how i can check image is exists in internal storage. if image does not exist it should display default image.

raju
  • 1
  • Do you have to check for any particular image or any image file? – Anku Agarwal Aug 20 '16 at 13:07
  • 1
    I'm not an android dev, so I'll abstain from flagging as a duplicate - but this *appears* to be a dupelicate of this: [Android; Check if file exists without creating a new one](http://stackoverflow.com/questions/16237950/android-check-if-file-exists-without-creating-a-new-one) – HPierce Aug 20 '16 at 14:21

1 Answers1

0

Try this for checking if the file exists.

 MediaScannerConnection.scanFile(
                        getApplicationContext(),
                        new String[]{YourFileName},
                        null,
                        new MediaScannerConnection.OnScanCompletedListener() {
                            @Override
                            public void onScanCompleted(String path, Uri uri) {
                                Log.v("Img",
                                        "file " + path + " Image exists " + uri);
                            }
                        });
Kunal Yadav
  • 139
  • 10