I have a sqlite table for my android application. This table has a String field (phone). When I want to insert or update a phone number starts with + plus-sign (e.g “+905331234567″) then it ignores the plus sign. It writes only 905331234567.
But when I modify the value with space (or any other except numeric) chars,
(eg.” +905331234567″), then no problem.
update friend set phone = "+905331234567"; //905331234567
update friend set phone = " +905331234567";// +905331234567
thanks for your reply.
kemal.
Edit
Create String:
private static final String CREATE_FRIEND = // create table
"create table " + FriendBean.DB_TABLE_NAME + "(" +
FriendBean.KEY_ROWID + " integer primary key autoincrement, " +
FriendBean.KEY_contactID + " String, " +
FriendBean.KEY_name + " String, " +
FriendBean.KEY_phone + " String, " +
FriendBean.KEY_accessCode + " String, " +
FriendBean.KEY_flag + " int " +
");";
Insert method:
public void insertFriend(FriendBean bean) {
SQLiteStatement statement = database.compileStatement(FriendBean.getInsertSQL());
statement.bindString(1,bean.getContactID());
statement.bindString(2,bean.getName());
statement.bindString(3,bean.getPhone() +"");
statement.bindString(4,bean.getAccessCode());
statement.bindLong(5,bean.getFlag());
long id= statement.executeInsert();
}
Class:
public class FriendBean{
public static final String DB_TABLE_NAME = "friend";
public static final String KEY_contactID = "contactID";
public static final String KEY_name = "name";
public static final String KEY_phone = "phone";
public static final String KEY_accessCode = "accessCode";
public static final String KEY_flag = "flag";
...
Solution:
String Fieldtype replaced with Text.
references
http://www.sqlite.org/datatype3.html
and
comments.
Solution:
String Fieldtype replaced with Text.
create table friend (rowid integer primary key autoincrement,
phone Text);
references