android - how do i perform method for all iteration of for loop -
my code delete 1st file using button click want delete , unhide images using loop if statement true if(checkarr[i] == true) code perform first index file ot checked file delete 1st 1 delete do? how delete , copy checked item? how customize loop??
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() + "'"); 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(); } }
i loop differently. i'd open database once, , i'd check see if intermediate steps working.
this more i'd recommend:
unhide.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { try { db.createdatabase(); (int = 0; < checkarr.length; i++) { if (checkarr[i] == true) { db = new database(getbasecontext()); cursor datac = db.selectquery("select path photos name ='"+ currentfiles[i].getname() + "'"); bitmap bitmap = decodefile.decodefile(new file(root + "/"+ currentfiles[i].getname())); if (datac.movetofirst() && bitmap != null) { fileoutputstream outputstream = new fileoutputstream(new file(datac.getstring(datac.getcolumnindex("path")))); outputstream.write(decodefile.getbitmapasbytearray(bitmap)); outputstream.close(); file file = new file(root + "/" + currentfiles[i].getname()); file.delete(); } else { if (bitmap == null) { log.v("your tag", "bitmap not found"); } else {} log.v("your tag", "unable convert file"); } datac.close(); } } db.close(); inflatelistview(currentfiles); } catch (exception e1) { e1.printstacktrace(); } } }
i'm not sure doing on things, that's direction i'd go in.
Comments
Post a Comment