What is the best way to list all rows in Sqlite Android ?

I'm currently using the following code to pass all items in some columns to Arrayadapter.

private void TestListAll(){
        //Displays the whole list.
        cursor = db.rawQuery("SELECT _id, firstName, lastName, title FROM employee WHERE firstName || ' ' || lastName LIKE ?", 
                  new String[]{"%" + "" + "%"});
        adapter = new SimpleCursorAdapter(
                new String[] {"firstName", "lastName", "title"}, 
                new int[] {R.id.firstName, R.id.lastName, R.id.title});

Is there a better method to accomplish this?


in my app i use somethink like this:

    public ArrayList<HashMap<String, ?>> selectLastPlayed() {
    ArrayList<HashMap<String, ?>> list = new ArrayList<HashMap<String, ?>>();
    Cursor cursor = this.db.query("employee Order BY ID DESC",
            new String[] { "*" }, null, null, null, null, null);
    if (cursor.moveToFirst()) {
        do {
            HashMap<String, Object> temp = new HashMap<String, Object>();
            temp.put("Icon", cursor.getString(1));
            temp.put("Title", cursor.getString(2));
        } while (cursor.moveToNext());
    if (cursor != null && !cursor.isClosed()) {
    return list;

and then, you can put arraylist into adapter ;) like this:

SimpleAdapter adapter = new MySimpleAdapter(this, selectLastSearch(), R.layout.custom_row_view, new String[] { "Icon", "Icon" }, new int[] { R.id.textView1123, R.id.imageView12 });

this is my simple adapter:

    public class MySimpleAdapter extends SimpleAdapter {
    Context localcontext = null;
    public MySimpleAdapter(Context context,List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {
        super(context, data, resource, from, to);
        localcontext = context;

    public View getView(int position, View convertView, ViewGroup parent) {
        View view = super.getView(position, convertView, parent);
        return view;

Need Your Help

copying files from multiple subfolders using vba

vba excel-vba access-vba

I've seen some documentation on this but so far, nothing that I've been able to replicate for my specific project.

.NET JIT potential error?

c# jit

The following code gives different output when running the release inside Visual Studio, and running the release outside Visual Studio. I'm using Visual Studio 2008 and targeting .NET 3.5. I've also

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.