if directory contain zero element code is blast
<p>im trying to use checkbox in my code after so much try i did it but i found one issue before adding checkbox in my code my code is goes inside a directory which contain no file   see this image</p>

<p><img src="http://i.stack.imgur.com/Yzy7J.jpg" alt="http://tinypic.com/view.php?pic=2zyda9f&amp;s=5">   </p>

<p>if any folder contain (0) image my code will blast .not goes inside and show empty grid if directory contain atleast (1) one image  mycode run perfectly what do i do? how do i handle null directory issue</p>

<pre><code>    GridView gridView;
TextView textView;
    File currentParent;
File[] currentFiles;
String[] currentFilePath;
    boolean CheckArr[]; 
    File root1;
LinearLayout ll;
String filePath;
String PhotosFolder = "Photos Folders";

SimpleAdapter simpleAdapter;

List&lt;ImageData&gt; imList;

Button del;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    del = (Button) findViewById(R.id.canceles);
    del.setOnClickListener(new OnClickListener() {      
        @Override
        public void onClick(View arg0) {

            for(int i=0;i&lt;CheckArr.length;i++)
            {
                if(CheckArr[i] == true)
                {

                        File file = new 
   File(imList.get(i).getImgPath());
                        file.delete();
                }
            }


            inflateListView(currentFiles);
        }
    });


    ll = (LinearLayout) findViewById(R.id.linearlayout1);
    viewLoad = LayoutInflater.from(FileGridActivity.this).inflate(
            R.layout.main, null);
    AddPictures = (ImageButton) findViewById(R.id.add_privacy_contact);

    Addfolder = (Button) findViewById(R.id.Addfolder);

    textView = (TextView) findViewById(R.id.title_name);
    File photos = new File(getFilesDir(), "Photos");
    photos.mkdirs();

    root1 = new File("/data/data/com.myexample/files/");

    currentParent = root1;
    currentFiles = root1.listFiles();


    currentFilePath = new String[currentFiles.length];
    int count = 0;

    for (File f : currentFiles) {
        currentFilePath[count] = f.getAbsolutePath();
        count++;

    }

    gridView = (GridView) findViewById(R.id.grid);
    gridView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                int position, long id) {

            if (currentFiles[position].isDirectory() ) {


                root = new File("/data/data/com.myexample/files/"+ 
             FileName(currentFilePath[position]) + "/");

                currentFiles = root.listFiles();
                inflateListView(currentFiles);
            } else if (currentFiles[position].isFile()) {
                openFile(currentFiles[position]);

                // gridposition = currentFiles[(int) id]);

            }           }
       });


              private void inflateListView(File[] files) {

    imList = new ArrayList&lt;ImageData&gt;();
    ImageData imObj;

    List&lt;Map&lt;String, Object&gt;&gt; listItems = new ArrayList&lt;Map&lt;String, Object&gt;&gt;();

    boolean check;

    for (int i = 0; i &lt; files.length; i++) {
        Map&lt;String, Object&gt; listItem = new HashMap&lt;String, Object&gt;();





        if (files[i].isDirectory()) {





            listItem.put("icon", R.drawable.folder);
            listItem.put("fileName",files[i].getName() + "(" + 
        files[i].list().length + ")");

            listItems.add(listItem);

            simpleAdapter = new SimpleAdapter(this, listItems, 
       R.layout.line,new String[] { "icon", "fileName" }, new int[] { 
           R.id.icon,R.id.file_name });
        //  gridView.invalidateViews();
            gridView.setAdapter(simpleAdapter);

        //  simpleAdapter.notifyDataSetChanged();

            check = false;
        } 
        else 
        {   
            check = true;
            imObj = new ImageData();




            listItem.put("icon", files[i]);

            listItems.add(listItem);

            imObj.setImgPath(files[i].toString());

            imList.add(imObj);

            }


        if(check == true)
        {
            imageAdapter = new          

ImagesAdapter(getApplicationContext(),FileGridActivity.this,0,imList);      
            gridView.setAdapter(imageAdapter);
            imageAdapter.notifyDataSetChanged();
        }
    }



  }

  public class ImagesAdapter extends ArrayAdapter&lt;ImageData&gt; {

    private LayoutInflater mInflater;

    List&lt;ImageData&gt; listItems;

    public ImagesAdapter(Context context,Activity activity, int 
       textViewResourceId, List&lt;ImageData&gt; items) {
            super(context, textViewResourceId, items);
            this.listItems = items;
            mInflater = LayoutInflater.from(context);

            CheckArr = new boolean[items.size()];

            for(int z = 0; z&lt;CheckArr.length;z++)
                CheckArr[z] = false;
    }

    public class ViewHolder{

           public CheckBox checkbox;
           public ImageView imageview;

    }

     public View getView(int position, View convertView, ViewGroup parent) {
            View vi=convertView;
            ViewHolder holder;

                vi = mInflater.inflate(R.layout.galleryitem, null);


                ImageData o = listItems.get(position);

                if(o != null){
                    holder = new ViewHolder();

                    holder.imageview = (ImageView) 
      vi.findViewById(R.id.thumbImage);
                    holder.checkbox = (CheckBox) 
   vi.findViewById(R.id.itemCheckBox);

                    File f = new 
      File(listItems.get(position).getImgPath());
                    holder.imageview.setImageBitmap(decodeFile(f));

                    holder.checkbox.setId(position);
                    holder.imageview.setId(position);

                    holder.checkbox.setOnCheckedChangeListener(new 
        OnCheckedChangeListener() {                 
                        public void 
       onCheckedChanged(CompoundButton arg0, boolean arg1) {
                            // TODO Auto-generated 
     method stub
                            Log.e("id",arg0.getId()+" 
      ");
                            Log.e("bool",arg1+ " ");

                            CheckArr[arg0.getId()] = 
        arg1;

                        }
                    });

                }

            return vi;

        }       
</code></pre>
