If I start my android app the app calls some data from a DB and save this data on the local SQL DB on the device. There is one value with a big number so I need BigInteger to store it. If I try to call that value from the local DB I get the error:
java.lang.NumberFormatException: Invalid BigInteger: 3.23431e+23
This is how I store the value in the local db:
...
values.put(BatteryEntryContract.BatteryEntry.COLUMN_NAME_SERVICE_TAG, String.valueOf(battery.get(i).getServiceTag()));
...
db.insert(BatteryEntryContract.BatteryEntry.TABLE_NAME_BATTERY, null, values);
This is how I call it from the local DB:
...
String serviceTagValue = cursor.getString(
cursor.getColumnIndexOrThrow(BatteryEntryContract.BatteryEntry.COLUMN_NAME_SERVICE_TAG));
batteryFromDb.setServiceTag(new BigInteger(serviceTagValue));
...
Do I have to format the value from the DB in a special way that I get in full length and not in the way with ...e+23?
EDIT: This is how the column type will be set:
...
BatteryEntry.COLUMN_NAME_SERVICE_TAG + " TEXT DEFAULT 0," +
....
When I try
...
values.put(BatteryEntryContract.BatteryEntry.COLUMN_NAME_SERVICE_TAG,
String.valueOf(battery.get(i).getServiceTag()));
...
Log.i("---",values+"");
db.insert(BatteryEntryContract.BatteryEntry.TABLE_NAME_BATTERY, null, values);
The value in the external DB is saved as numeric(24,0)
when I get it from there I save it as String in the local DB. when I do Log.i("---",values+"");
("values" will be saved in the local DB) the number will be displayed correct:
.... serviceTag=323431303230313631333331 ....