0

I want to display a single row from the database in a listview.

For example: I have a database with three row and 4 columns. I want to display the columns from row 2 as a listview (but i only want to display the columns that contains data).

I dont have any code, because i dont even know where to start. I only used the simplecursoradapter in the past.

Sorry for my bad english. I searched a lot and didnt find any answer. Please dont be too rude if thats a stupid question.

Gernot
  • 1

1 Answers1

0

Okay now collect your data in cursor just get all your data and store each row object in a ArrayList of the wrapperClass object like

Cursor c=null;
        c=db.getAllRecords();
        if(c.getCount()>0)
        {
            for(int j=0;j<c.getCount();j++)
            {
                c.moveToPosition(j); 
                employeewrapper cw=new employeewrapper();
                cw.id=c.getLong(0);
                cw.name=c.getString(1);
                cw.phone=c.getString(2);
                cw.web=c.getString(3);
                cw.address=c.getString(4);
                cw.des=c.getString(5);
                cw.qual=c.getString(6);
                cw.doj=c.getString(7);
                cw.sal=c.getString(8);
                if(cw.des.equalsIgnoreCase("Designer"))
                {
                designers.add(cw);
                }
                } 
        }   
        c.close();
        db.close();

npw you can display any row you want create a new ArrayList of string to store names and pass that arraylist to the adapter in this way you can easily display your data and may be able to transfer it anywhere you want easily

Aashish Bhatnagar
  • 2,595
  • 2
  • 22
  • 37
  • Hi. Thank you for the answer. I forgot to mention that i wanna make the entrys in the listview deletable. So an Arraylist wont work. – Gernot Apr 08 '12 at 21:48
  • I dont want to delete the item from the list. I want to delete the value of the column the database. – Gernot Apr 09 '12 at 14:20