Note that there are some explanatory texts on larger screens.

plurals
  1. POSimply populate database table names in Android ListView
    text
    copied!<p>Very new to Android development...I've been scouring the internet for answers, but I'm still finding myself stuck and hoping someone can lend me a hand. I absolutely admit I am a newbie...but trying to learn.</p> <p>I have an already populated sqlite database that I am including in a package. I've copied this into the asset folder. The database has 4 tables (and some fields beneath that).</p> <p>I have a simple activity with a listview that I am trying to simply query the database for the table names and have them populate, however I get no results.</p> <p>my DataBaseAdapter code is essentially the code from here: <a href="http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/" rel="nofollow">http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/</a></p> <p>I modified my database name and path. </p> <p>My class code to call this is here: </p> <p>ON EDIT:::</p> <pre><code>public Cursor fetchAllNotes() { return myDbHelper.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", new String[]{}); } private void fillData() { Cursor c = fetchAllNotes(); startManagingCursor(c); String[] from = new String[] {"name"}; int[] to = new int[] {R.id.listview}; SimpleCursorAdapter notes = new SimpleCursorAdapter (this, R.layout.list_view, c, from, to); setListAdapter(notes); } } </code></pre> <p>The project runs, it just yields no results in the ListView (which is in an xml named lists.xml) the portion of code is here:</p> <pre><code> &lt;ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;TextView android:id="@android:id/empty" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:text="No data" style="@style/ButtonText"/&gt; </code></pre> <p>Any help would be great, I'm sure I am flailing hard on my sql calls...but I am stuck. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload