android - how to delete all check file using for loop? -
this code deletes first checked file.
i want delete checked files, changed need make?
how collect values in checkarr[i]?
the code deletes first checked file in grid. want first collect checked values true make database call(s).
boolean checkarr[]; file[] currentfiles; unhide.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { (int = 0; < 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 photos name ='" + currentfiles[i].getname() + "'"); if (datac.getcount() > 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(); } }
you have add loop cursor datac delete files , not first one.
if (datac.getcount() > 0) { while (datac.movetonext()) { //... } }
Comments
Post a Comment