android - Can I ask an advice for the algorithm of retrieving arrayList in Java? -



android - Can I ask an advice for the algorithm of retrieving arrayList in Java? -

i have class in java such this

for (....) { tarik_id.add(id); }

which tarik_id list<string> , want add together (id) written in tarik_id arraylist. , then....

hasil = db.getdetailresult(tarik_id);

getdetailresult class selecting (id) have pulled out tarik_id. , hasil 2 dimensional table (list.list.string..)

i think tarik_id doesn't homecoming value in sec line above. have tried log.i id, , logcat returns true values of id. question how can tarik_id in .getdetailresult returns of array values?

make code following:

// set first id in first stringbuilder stringbuilder = new stringbuilder(id.get(0)); // start loop 2nd (i=1; < idlist.size(); i++) { stringbuilder.append(",").append(id.tostring()); } string ids = stringbuilder.tostring() hasil = db.getdetailresult(ids);

change code in getdetailresult() query like

if(ids.equals("")){ homecoming null; } string sql = "select * from...... id in("+ids+").....";

i think much faster, records in 1 nail , no need sec loop.

java android

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -