Android:how to retrieve values from String variable or object
<p>i have all my students data in s variable i.e first name,last name,id. which i have retrieved from list view.now i want to retrieve data from s variable to individual string variables like,i want to store first name in one string,last name in another string.like i have done below.but its not working.</p>

<p>i tried to iterate also but its giving error..can any one suggest me some idea of how can i retrieve values from s variable.</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.thrd);
     Log.i("INFO","ALL DETAILS");
     mydb=new MyDataBase(four.this);
     mydb.openDB();
     lv = (ListView)findViewById(R.id.listView1);  
     save = (Button) findViewById(R.id.button2);

     save.setOnClickListener(new OnClickListener(){
         public void onClick(View arg0) {
             long[] v=  lv.getCheckedItemIds();
             String s1=v.toString();
             int h =lv.getCount();
             for(int i=0;i&lt;lv.getCount();i++) {
                 Object p2  =   lv.getItemAtPosition(i);
                 String s=(String) p2.toString();
                 List&lt;? extends Map&lt;String, ?&gt;&gt; s4=(List&lt;? extends Map&lt;String, ?&gt;&gt;) p2;
                 SimpleAdapter mSchedule1 = new SimpleAdapter(four.this, s4, R.layout.col1,
                         new String[] {"clss","sec","_Sid","FName", "LName"}, new int[] {R.id.editText1, R.id.editText2,R.id.editText3,R.id.editText4,R.id.editText5});
                 lv1.setAdapter(mSchedule1);
                 EditText cls=(EditText)findViewById(R.id.editText1);
                 EditText  sec=(EditText)findViewById(R.id.editText2);
                 EditText  sid=(EditText)findViewById(R.id.editText3);
                 EditText  fname=(EditText)findViewById(R.id.editText4);
                 EditText  lanme=(EditText)findViewById(R.id.editText5);

                 final  String cl=cls.getText().toString();
                 final  String sec1=sec.getText().toString();
                 final  String sid1=sid.getText().toString();
                 final  String fn=fname.getText().toString();
                 final String ln=lanme.getText().toString();
                 final String p="present";

                 Toast.makeText(four.this, sec1, Toast.LENGTH_LONG).show();
             }
         }
     });
     showall=(Button)findViewById(R.id.button1);
     showall.setOnClickListener(new OnClickListener() {
         public void onClick(View v) {
             // TODO Auto-generated method stub
             ArrayList&lt;HashMap&lt;String,String&gt;&gt; p2 = mydb.getAllSDetails();
             SimpleAdapter mSchedule = new SimpleAdapter(four.this, p2, R.layout.column,
                     new String[] {"_Sid","FName", "LName"}, new int[] {R.id.txtfname, R.id.txtlname,R.id.txtage});
             lv.setAdapter(mSchedule);
             lv.setOnItemClickListener(select);
             // int h=   lv.getCount();
         }
     });
}

public OnItemClickListener select=new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) {
        int idd[] = mydb.gettingId();
        str = idd[position];
    }
};
</code></pre>

<p>my error log</p>

<p>12-29 16:38:51.849: E/AndroidRuntime(561): FATAL EXCEPTION: main
12-29 16:38:51.849: E/AndroidRuntime(561): java.lang.ClassCastException: java.util.HashMap
12-29 16:38:51.849: E/AndroidRuntime(561):  at com.android.four$2.onClick(four.java:85)
12-29 16:38:51.849: E/AndroidRuntime(561):  at android.view.View.performClick(View.java:2408)
12-29 16:38:51.849: E/AndroidRuntime(561):  at android.view.View$PerformClick.run(View.java:8816)
12-29 16:38:51.849: E/AndroidRuntime(561):  at android.os.Handler.handleCallback(Handler.java:587)
12-29 16:38:51.849: E/AndroidRuntime(561):  at android.os.Handler.dispatchMessage(Handler.java:92)
12-29 16:38:51.849: E/AndroidRuntime(561):  at android.os.Looper.loop(Looper.java:123)
12-29 16:38:51.849: E/AndroidRuntime(561):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-29 16:38:51.849: E/AndroidRuntime(561):  at java.lang.reflect.Method.invokeNative(Native Method)
12-29 16:38:51.849: E/AndroidRuntime(561):  at java.lang.reflect.Method.invoke(Method.java:521)
12-29 16:38:51.849: E/AndroidRuntime(561):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-29 16:38:51.849: E/AndroidRuntime(561):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-29 16:38:51.849: E/AndroidRuntime(561):  at dalvik.system.NativeStart.main(Native Method)</p>
