I'm having trouble with a SQLite database that I have on the SDCard.
when I do a query that returns a cursor I keep getting an error when i
try to call the count() method.
Here's the code
Cursor cursor = mDb.query
(LOGON_TABLE, // table
new String[] { KEY_ROW_ID },
//
columns,
KEY_USER_NAME + " = ? AND " +
KEY_CARRIER_ID + " = ? AND " +
KEY_DEPOT + " = ? AND " +
KEY_TIME + " = ? AND " +
KEY_RUN + " = ?",
//selection,
new String[] { user, carrier, depot, logonTime,
run },//
selectionArgs,
null, null, null,
//
groupBy, having, orderBy
" 1
"); //
limit
if (cursor.getCount() < 1) { <--error occurs here
...
}
It gives a datatype mismatch as a result of calling count...
10-22 04:20:21.330: ERROR/AndroidRuntime(15768):
android.database.sqlite.SQLiteException: datatype mismatch
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
android.database.sqlite.SQLiteQuery.native_fill_window(Native Method)
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:75)
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:288)
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:269)
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
android.database.AbstractCursor.moveToPosition(AbstractCursor.java:
171)
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
android.database.AbstractCursor.moveToFirst(AbstractCursor.java:248)
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
com.paperfree.database.DatabaseService.insertLogon
(DatabaseService.java:288)
10-22 04:20:21.330: ERROR/AndroidRuntime(15768): at
com.paperfree.load.LoadView$2.onServiceConnected(LoadView.java:76)
10-22 04:53:20.471: ERROR/AndroidRuntime(22252):
android.database.sqlite.SQLiteException: datatype mismatch
10-22 04:53:20.471: ERROR/AndroidRuntime(22252): at
android.database.sqlite.SQLiteQuery.native_fill_window(Native Method)
10-22 04:53:20.471: ERROR/AndroidRuntime(22252): at
android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:75)
10-22 04:53:20.471: ERROR/AndroidRuntime(22252): at
android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:288)
10-22 04:53:20.471: ERROR/AndroidRuntime(22252): at
android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:269)
10-22 04:53:20.471: ERROR/AndroidRuntime(22252): at
com.paperfree.database.DatabaseService.insertLogon
(DatabaseService.java:268)
The database file is on the sdCard and all the columns are there, but
I haven't put any data there so I am expexcting a cursor with zero
rows.
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---