-3

*for example [image is attached]**

sample values are colomn1, colomn2. After fetching values I should display them row by row. Please help me here.

sample table

 public ArrayList<String> getAllData(){
    ArrayList<String> array_list = new ArrayList<String>();
    //hp=new HashMap();
    SQLiteDatabase db=this.getReadableDatabase();
    Cursor res=db.rawQuery("select * from spendlist", null);
    res.moveToFirst();
    if (res != null && res.moveToFirst() ){
        while (!res.isAfterLast()) {
            array_list.add(res.getString(res.getColumnIndex(SPEND_LIST_COLUMN_DESC)));
            res.moveToNext();
        }
    }
    return array_list;
}

above code i am using to fetch data to populate it i am using

 ArrayList array_list = mydb.getAllData();
    ArrayAdapter arrayAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1, array_list);

    obj = (ListView)findViewById(R.id.listView1);
    obj.setAdapter(arrayAdapter);

Now I want to fetch all data instead one column and populate it

Ram
  • 1
  • 1

2 Answers2

0

This is a very broad question, so unfortunately I can only give a very broad answer. A CursorAdapter might be the simplest way to solve your problem.

keith
  • 3,105
  • 2
  • 29
  • 34
0

What you need is ListView, a custom layout for each item list and an ArrayAdapter. You can check this answer for inspiration.

Community
  • 1
  • 1
  • hi, I am using ArrayAdpter but to display one value. [code attached above] now I want to display 2 values. – Ram Feb 25 '16 at 16:28