Open top menu

we will implement array code how to update array in android. you can try this code
first, you have create a string array inside onCreate() overide method.

ArrayList<String> qtyidList = new ArrayList<String>();

second, you have to insert  value in String ArrayList,

for(int i=0; i<10; i++){
qtyidList .add(i+":\t"+"items")
}


output:

0 item
1 item
2 item
3 item
4 item
5 item    // you want update in this stack
6 item
7 item
8 item
9 item


// qtyidList.set(<int index>,<your string>)
qtyidList.set(6,"Android beginnerpoint tutorial");

then update the value same index in array.

 output:
0 item
1 item
2 item
3 item
4 item
Android beginnerpoint tutorial    //   update
6 item
7 item
8 item
9 item

...................Remove the particular array index, try this code.............................
qtyidList.remove("7");

 output:
0 item
1 item
2 item
3 item
4 item
Android beginnerpoint tutorial    //   update
7 item  // remove the index but item 7 or 8 and item 9 shift.
8 item
9 item


Tagged

0 comments