android - Cursor returning wrong values
I'm querying some products in SQLite database, but same base in 2 differents android's versions return differents values.
Select result in database.db3 using SQLite Expert:
I create this code after select, to test:
if(cursor.moveToFirst()){
while(!cursor.isAfterLast()){
log("CDPROD:" + cursor.getString(cursor.getColumnIndex("CDPROD")));
cursor.moveToNext();
}
}
Log Result in android 2.2:
09-26 14:30:08.947: INFO/LOGG(20497): CDPROD:000000000000211934
09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000211944
09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000212020
09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000212124
09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000214280
09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000212886
Log Result in android 2.1:
09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:211934
09-26 14:18:16.772: INFO/LOGG(1039): C开发者_JAVA技巧DPROD:211944
09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:212020
09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:212124
09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:214280
09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:212886
This is a bug in Android??
Ty
You need to use as the column type text
not string
or varchar
when you create your SQLiteTables
. It seems that if you put string
it will trim
your leading zeros
. Also see SQLite Data Types.
EDIT: According to this answer: Versions of SQLite in Android, they have diffrent SQLite versions
.
精彩评论