I want to store the data which is shown by setListAdapter to sqlite .. how ca i ?? please help me
XML File http://p-xr.com/xml
package com.pxr.tutorial.xmltest;
import java.util.ArrayList;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
public class Main extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listplaceholder);
ArrayList> mylist = new ArrayList>();
String xml = XMLfunctions.getXML();
Document doc = XMLfunctions.XMLfromString(xml);
int numResults = XMLfunctions.numResults(doc);
if((numResults map = new HashMap();
Element e = (Element)nodes.item(i);
map.put("id", XMLfunctions.getValue(e, "id"));
map.put("name", "Naam:" + XMLfunctions.getValue(e, "name"));
map.put("Score", "Score: " + XMLfunctions.getValue(e, "score"));
mylist.add(map);
}
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main,
new String[] { "id","name", "Score" },
new int[] {R.id.id, R.id.item_title, R.id.item_subtitle });
setListAdapter(adapter);
/* final ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View view, int position, long id) {
@SuppressWarnings("unchecked")
HashMap o = (HashMap) lv.getItemAtPosition(position);
Toast.makeText(Main.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_LONG).show();
}
});*/
}
}
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, new String[] { "id","name", "Score" }, new int[] {R.id.id, R.id.item_title, R.id.item_subtitle }); setListAdapter(adapter);see this code... – Ajay Patel Apr 19 '11 at 04:48