how to delete all check file using for loop?
<p>This is my code which deletes only the first checked file.  </p>

<p>I want to delete all checked files, what changed do I need to make?</p>

<p>How do I collect all values in CheckArr[i]? </p>

<p>The code only deletes the first checked file in grid.  I want to first collect all checked values which are true then make database call(s).</p>

<pre><code>boolean CheckArr[];
File[] currentFiles;

unhide.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View arg0) {

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

                db = new DataBase(getBaseContext());
                try {
                    db.createDataBase();
                } catch (IOException e1) {

                    e1.printStackTrace();
                }


                Cursor DataC = db
                    .selectQuery("SELECT path FROM Photos where name ='" +
                    currentFiles[i].getName() + "'");



                if (DataC.getCount() &gt; 0) {
                    Bitmap bitmap =
                        decodeFile.decodeFile(new File(root + "/" + currentFiles[i].getName()));

                    try {
                        FileOutputStream
                        outputStream = new FileOutputStream(
                            new File(DataC.getString(DataC
                            .getColumnIndex("path"))));

                        outputStream.write(decodeFile.getBitmapAsByteArray(bitmap));
                        outputStream.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }


                    File file = new File(root + "/" +
                        currentFiles[i].getName());
                    file.delete();

                    inflateListView(currentFiles);

                }

                DataC.close();
                db.close();
            }
        }           
</code></pre>
