2

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:

result

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): CDPROD: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

Rodrigo
  • 5,435
  • 5
  • 42
  • 78

1 Answers1

0

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.

Community
  • 1
  • 1
Ovidiu Latcu
  • 71,607
  • 15
  • 76
  • 84