I am trying to display table data in tabular form in android program.
My table:
orderno productid productqty custid
1 1000001 2 00010
2 1000001 5 00010
I want display that table in the android front end. For that I write the following program:
dbadapter.open();
Cursor cursor=dbadapter.fetchordersdata(custid);
int count=cursor.getCount();
From this I am getting the table data. How can I arrange this data in tabular form?
get data from database and append data to string and load this str to web view follow this code
String mStr="";
mStr=mStr.concat("<body >");
mStr=mStr.concat("<tr><td align='center'><b>orderno</b></td><td align='center'><b>productid</b></td><td align='center'><b>productqty</b></td>
<td align='center'><b>custid</b></td></tr>");
dbadapter.open();
Cursor cursor=dbadapter.fetchordersdata(custid);
cursor.moveToFirst();
while(!cursor.isAfterLast())
{
mStr=mStr.concat("<tr><td>"+(cursor.getString(cursor.getColumnIndex("col1")))+"</td><td>"+(cursor.getString(cursor.getColumnIndex("col2")))+"</td>
<td>"+(cursor.getString(cursor.getColumnIndex("col3")))+"</td>
<td>"+(cursor.getString(cursor.getColumnIndex("col4")))+"</td></tr>");
cursor.moveToNext();
}
mStr.concat("</table></body>");
i hope this code will help u... WebView web =(WebView)findViewById(R.id.webview); web.loadData(mStr,"text/html",null);