Well, I did do a check on the cursor.getCount() and it did return a value of 1, which is what I was expecting. So, the issue must be with displaying the data. Here is my code for populating the data and displaying it, which I've taken from the notepad tutorial. Would appreciate any help.

private void getAllPlayers() {
        // Get all of the notes from the database and create the item list
//playerCursor = dbHelper.queryTable(PLAYERS_TABLE, ALL_PLAYER_COLS, null, null, null, null, null);
        playerCursor = dbHelper.rawQuery("SELECT * FROM players;");
        int pCount = playerCursor.getCount();
        startManagingCursor(playerCursor);

String[] plyData = new String[] { PLAYERS_SEX, PLAYERS_NAME, PLAYERS_HANDICAP }; int[] plyCols = new int[] { R.id.plyIcon ,R.id.plyName, R.id.plyHandicap };

        // Now create an array adapter and set it to display using our row
        ListAdapter plyAdapter =
new SimpleCursorAdapter(this, R.layout.players_rows, playerCursor, plyData, plyCols);
        setListAdapter(plyAdapter);
    }

My 2 layouts for this are as follows:
*playerslist.xml*
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
<ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:gravity="left"
        />
<TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Name"
        android:textSize="20sp"
        android:layout_weight="1"
        android:textColor="#FFFF00"
        android:gravity="center"
        />
<TextView android:textSize="20sp"
        android:id="@+id/textView1"
        android:layout_height="wrap_content"
        android:textColor="#FFFF00"
        android:text="Handicap"
        android:layout_weight="0"
        android:gravity="right"
        android:layout_width="wrap_content"
    />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
<ListView android:id="@android:id/list"
          android:paddingBottom="10px"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
<TextView android:id="@android:id/empty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/no_players"/>
</LinearLayout>
</LinearLayout>


*players_rows.xml*
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">
<ImageView
        android:id="@+id/plyIcon"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:gravity="left"
        />
<TextView
          android:id="@+id/plyName"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textSize="14sp"
          android:textColor="#FFFFFF"
          android:gravity="left">
</TextView>
<TextView
          android:id="@+id/plyHandicap"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textSize="14sp"
          android:textColor="#FFFFFF"
          android:gravity="right">
</TextView>
</LinearLayout>
------------------------------------------------------------------------

David Williams
Check out our WebOS mobile phone app for the Palm Pre and Pixi:
<http://www.dtw-consulting.com/GolfCaddie> Golf Caddie <http://www.dtw-consulting.com/GolfCaddie> | Golf Caddie Forum <http://www.dtw-consulting.com/GolfCaddie/forum> | Golf Caddie FAQ <http://www.dtw-consulting.com/GolfCaddie/faq.html> by DTW-Consulting, Inc.



On 4/21/2011 9:25 AM, Kostya Vasilyev wrote:

Maybe the data was never inserted into the table to begin with?

"Select * from some_table" is pretty much as low-level as you can get for testing (short of copying the database off the device to use the command line sqlite3 tool).

You could also try calling cursor.getCount() as a sanity check.

21.04.2011 17:21 пользователь "David Williams" <[email protected] <mailto:[email protected]>> написал:
> Thanks for that. I am also stopping and debugging the code when reading
> and displaying the cursor, but I am still not seeing anything.
> The code is what is used in the notepad tutorial so it obviously works
> there.
>
> private void getAllPlayers() {
> // Get all of the notes from the database and create the item list
> //playerCursor = dbHelper.queryTable(PLAYERS_TABLE,
> ALL_PLAYER_COLS, null, null, null, null, null);
> playerCursor = dbHelper.rawQuery("SELECT * FROM players;");
>
> startManagingCursor(playerCursor);
>
> String[] from = new String[] { PLAYERS_NAME };
> int[] to = new int[] { R.id.playerData };
>
> // Now create an array adapter and set it to display using our row
> SimpleCursorAdapter players =
> new SimpleCursorAdapter(this, R.layout.players_rows,
> playerCursor, from, to);
> setListAdapter(players);
> }
> ------------------------------------------------------------------------
>
> David Williams
> Check out our WebOS mobile phone app for the Palm Pre and Pixi:
> <http://www.dtw-consulting.com/GolfCaddie> Golf Caddie
> <http://www.dtw-consulting.com/GolfCaddie> | Golf Caddie Forum
> <http://www.dtw-consulting.com/GolfCaddie/forum> | Golf Caddie FAQ
> <http://www.dtw-consulting.com/GolfCaddie/faq.html> by DTW-Consulting, Inc.
>
>
>
> On 4/21/2011 12:57 AM, Zsolt Vasvari wrote:
>> The Cursor won't get filled until you try to retrieve the first row.
>> So if you are stopping the program on the rawQuery, you won't see
>> anything.
>>
>> On Apr 21, 9:03 am, David Williams<[email protected] <mailto:[email protected]>>
>> wrote:
>>> Tried that but it didn't make any difference.
>>>
>>> This is weird and I can't work out why the query is not returning any rows.
>>> Is there something else in the debugger I need to be looking at? As
>>> mentioned before, when I copy the DB down to my computer I can see that
>>> there are records there created when my app is first launched.
>>>
>>> Does the NO_COUNT = -1 (for the cursor) mean that no rows were returned? >>> ------------------------------------------------------------------------
>>>
>>> David Williams
>>> Check out our WebOS mobile phone app for the Palm Pre and Pixi:
>>> <http://www.dtw-consulting.com/GolfCaddie> Golf Caddie
>>> <http://www.dtw-consulting.com/GolfCaddie> | Golf Caddie Forum
>>> <http://www.dtw-consulting.com/GolfCaddie/forum> | Golf Caddie FAQ
>>> <http://www.dtw-consulting.com/GolfCaddie/faq.html> by DTW-Consulting, Inc.
>>>
>>> On 4/19/2011 10:20 PM, lbendlin wrote:
>>>
>>>
>>>
>>>> Would you be willing to try a raw query?
>>>> Cursor c = db.rawQuery("SELECT * FROM players", null);
>>>> if (c != null) {
>>>> if (c.moveToFirst()) {
>>>> do {
>>>> int id = c.getInt(0);
>>>> // other fields etc
>>>> } while (c.moveToNext());
>>>> }
>>>> c.close();
>>>> }
>>>> Might be easier to debug.
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Android Developers" group.
>>>> To post to this group, send email to [email protected] <mailto:[email protected]>
>>>> To unsubscribe from this group, send email to
>>>> [email protected] <mailto:android-developers%[email protected]>
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/android-developers?hl=en- Hide quoted text -
>>> - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected] <mailto:[email protected]>
> To unsubscribe from this group, send email to
> [email protected] <mailto:android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

<<inline: GClogo.png>>

Reply via email to