Android:retrieving data from checked chekbox if loop
<p>I want to retrive my data from list view which has multiple rows and columns which I have done and is working fine. But now what I want is that i have to retrive data from list view if the check box is checked it should go to if loop and if the check box is not checked it should go to else loop.the code which I have done to retrive all data from list view is as pasted below and is working.</p>

<pre><code>ListView lv;

for(int i=0;i&lt;lv.getCount();i++)
                    {
                         p2 =   lv.getItemAtPosition(i);


                     s=(String) p2.toString();
                    m(s);

                     }



                }
            });
void m(String ss)
        {

            String m3 = null,m6 = null,m15 = null,m9 = null,m12 = null,o = null;
            String s = null;
            String t[]= ss.split(",");
            for(int y=0,i=0;y&lt;1;y++,i++)
            {

        String m=t[i];//0
        String[] m2=m.split("=");
         m3=m2[1];//1 fn

        String m4=t[++i];//2 sid
        String[] m5=m4.split("=");
         m6=m5[1];


        String m7=t[++i];//cls
        String[] m8=m7.split("=");
         m9=m5[1];

        String m10=t[++i];//sec
        String[] m11=m10.split("=");
         m12=m11[1];

        String m13=t[++i];//ln
        String[] m14=m10.split("=");
         m15=m11[1];

                 o="present";
            mydb.insertSDetails1(m6,m3,m15,m9,m12,o);

                    }   
        }
</code></pre>

<p>The above code is for retrieving all data. Now I want if the check box of that row is checked it should go to if loop or else it should go to else loop. I have tried to google it out but I found no suitable answer to my question. I want to do like code shown below. But it is not exactly correct. Can any one guide me how to do it.</p>

<pre><code>                  lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

           SparseBooleanArray checked = lv.getCheckedItemPositions();


for (int i = 0; i &lt; checked.size(); i++) {

                if(checked.valueAt(i) == true) {
                    ListView tag = (ListView) lv.getItemAtPosition(checked.keyAt(i));
                Object p3=tag.getItemAtPosition(i);

                String  st=(String) p3.toString();

                m(st);

                }
                else
                {
                    //do some stuff here.
                }
</code></pre>
