I've created an SQLiteDatabase in my app and populated it with some data. I can connect to my AVD with a terminal and when I issue select * from articles; I get a list of all the rows in my table and everything looks fine. However, in my code when I query my table, I get a cursor back that has my tables columns, but zero rows of data. Here is my code..
mDbHelper.open();
Cursor articles = mDbHelper.fetchAllArticles();
startManagingCursor(articles);
Cursor feeds = mDbHelper.fetchAllFeeds();
startManagingCursor(feeds);
mDbHelper.close();
int titleColumn = articles.getColumnIndex("title");
int feedIdColumn = articles.getColumnIndex("feed_id");
int feedTitleColumn = feeds.getColumnIndex("title");
/* Check if our result was valid. */
if (articles != null) {
int count = articles.getCount();
/* Check if at least one Result was returned. */
if (articles.moveToFirst()) {
In the above code, my Cursor articles returns with my 4 columns, but when I call getCount() it returns zero, even though I can see hundreds of rows of data in that table from command line. Any idea what I might be doing wrong here?
Also.. here is my code for fetchAllArticles..
public Cursor fetchAllArticles() {
return mDb.query(ARTICLES_TABLE, new String[] {ARTICLE_KEY_ROWID, ARTICLE_KEY_FEED_ID, ARTICLE_KEY_TITLE,
ARTICLE_KEY_URL}, null, null, null, null, null);
}
Rob W.