android - What is going wrong in this? -


I am bringing a list of tables from the database I am using this code to get the list of tables: / P>

  public zeros show allTable () {db.execSQL ("select name from sqlite_master where type = 'table'"); }   

This query executes in the shell window.

Now I want to display a list of tables in Android. How could this be possible? I am calling this function from some other activity.

Edited: Thanks for the stack overflow, I found.

The usual way of displaying a list of data is to use a ListView to do this You will need to:

1: Store db.query values ​​in the list by changing db.query instead of db.exec:

  ArrayList & LT; String & gt; Tables = new Arsuachee & lt; String & gt; (); Cursor mCursor = db.query ("sqlite_master", new string [] {"name"}, "type = table", null, null, null, null); If (mCursor.getCount ()> gt; {for (mCursor.moveToFirst),! MCursor.isAfterLast (), mCursor.moveToNext ()) {tables.add (mCursor.getString (0)); }} / ** Essentials! Always close cursor and dB * / mCursor.close (); Db.close (); Return table;   

2: Use a list view and an array adapter to display information. See how to do this.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -