加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如果字符串字段以加号()开头,则更新Sqlite表?

发布时间:2020-12-12 18:54:17 所属栏目:百科 来源:网络整理
导读:我的 android应用程序有一个sqlite表.该表有一个字符串字段(电话).当我想插入或更新电话号码以加号开头(例如“905331234567”)时,它会忽略加号.它只写905331234567. 但是当我用空格(或任何其他除数字)字符修改值时, (例如“905331234567”),那没问题. update
我的 android应用程序有一个sqlite表.该表有一个字符串字段(电话).当我想插入或更新电话号码以加号开头(例如“905331234567”)时,它会忽略加号.它只写905331234567.
但是当我用空格(或任何其他除数字)字符修改值时,
(例如“905331234567”),那没问题.

update friend set phone = "+905331234567"; //905331234567
update friend set phone = " +905331234567";// +905331234567

感谢您的回复.
凯末尔.

编辑

创建字符串:

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 " +
        ");";

插入方法:

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();
}

类:

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";
    ...

解:
String Fieldtype替换为Text.

引用
http://www.sqlite.org/datatype3.html

评论.

解决方法

解:

String Fieldtype替换为Text.

创建表朋友(rowid整数主键自动增量,
????????手机文字);

引用

> http://www.sqlite.org/datatype3.html>评论.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读