I have gone through the notepad tutorial and I am trying to pull data
out of a table, which I know has 1 record in the table, and display the
data.
From running a debug it looks as though the query is not returning any
data.
I have a DBHelper.java class that does all the DB work and part of that
class contains the following code:
public Cursor queryTable(String *table*, String[] *cols*, String
selection, String[] args, String groupBy, String having, String orderBy
) throws SQLException {
dbHelper = new DatabaseHelper(dbCtx);
db = dbHelper.getWritableDatabase();
Cursor cAllPlayers = db.query(table, cols, selection, args,
groupBy, having, orderBy);
return cAllPlayers;
}
I am basically passing in players (for table) and a list of all the
columns for that table (for cols) into this code. From what I can tell
from debug the query that this is building is:
SELECT _id, name, handicap, sex, owner FROM players
This is what I'd expect and when I copy the app DB to my computer and
run the above I get 1 row of data, as expected.
When I examine the cursor in Debug I can also see the following:
NO_COUNT = -1
mCount = -1
Here is the other piece of code that calls the above queryTable:
private void getAllPlayers() {
playerCursor = dbHelper.queryTable(PLAYERS_TABLE,
ALL_PLAYER_COLS, null, null, null, null, null);
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 notes =
new SimpleCursorAdapter(this, R.layout.players_rows,
playerCursor, from, to);
setListAdapter(notes);
}
Not sure what else to look at to try and determine why the query is not
working.
Would appreciate any help.
--
------------------------------------------------------------------------
David Williams
Check out our WebOS mobile phone app for the Palm Pre and Pixi:
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.
--
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