i have a Problem with String[] array.I refer about this from Here & Here
But still, i have not found any solution from the link.
What I want:
I am developing a Custom Camera App.I have a Folder in which I am saving a Captured images.also, i have 1 ImageView. when my App Launched the Image [or Bitmap] of Folder is set into that ImageView (Always set the First image of the folder into ImageView).
Following is my Code.
private void loadImageInImageView() {
        Uri[] mUrls;
        String[] mFiles = new String[0];
        File file = new File(android.os.Environment.getExternalStorageDirectory(), "CameraApp/Images");
        File[] imageList = file.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File file, String name) {
                return ((name.endsWith(".jpg")) || (name.endsWith(".png")) || (name.endsWith(".mp4")));
            }
        });
        if (mFiles.length >= 0) {
            Toast.makeText(this, "No Captured Images", Toast.LENGTH_SHORT).show();
        } else {
            mFiles = new String[imageList.length];
            for (int i = 0; i < imageList.length; i++) {
                mFiles[i] = imageList[i].getAbsolutePath();
            }
            mUrls = new Uri[mFiles.length];
            for (int i = 0; i < mFiles.length; i++) {
                mUrls[i] = Uri.parse(mFiles[i]);
                imgBtnThumbnail.setImageURI(mUrls[i]);
            }
        }
    }
in Above code [when Folder is Empty] :
- When i set - if (mFiles.length > 0)- it shows me an Error 
Error: Attempt to get length of null array
- When i set - if (mFiles.length >= 0)- Then it shows me same as Above Error. 
- When i set - if (mFiles == null)- it is also not Working because I have initialized String[] in above code. - String[] mFiles = new String[0];Hence it also not work.
When I have some Images then it working Fine.because it executed the else part. what should I do?Whenever my Folder is Empty then it Shows me a Toast.otherwise my else code will be executed.
Any help will be Highly appreciated.
 
     
     
     
     
    