I have an insert query, it adds the contacts on the database. However, I have a problem with inserting a string that has "0" as its first character.
For example I input this: 09127400049
It will now be saved as:
9127400049
public void addEmergencyContacts(String name, long number, String email, String relationship) {
ContentValues cv = new ContentValues();
cv.put("NAME", name);
cv.put("NUMBER", number);
cv.put("EMAIL", email);
cv.put("RELATIONSHIP", relationship);
this.getWritableDatabase().insertOrThrow("ELSA_EMERGENCY_CONTACTS", "", cv);
}
Here's how I insert contacts
controller.addEmergencyContacts(emergencyContactET.getText().toString(), Long.parseLong(emergencyNumberET.getText().toString()), emergencyEmailET.getText().toString(), relationship);
Do you know any solutions or suggestion there
To insert the 0 character you will need to do the following:-
public void addEmergencyContacts(String name, long number, String email, String relationship) {.....
to public void addEmergencyContacts(String name, String number, String email, String relationship) {.....
addEmergencyContacts
to pass the value for the 2nd parameter as a string ensuring that the leading 0 is included in that string.The reasoning is that in order to be flexible and efficient SQLite :-
Rather than go into great detail here's a link detailing the factors Datatypes In SQLite Version 3.