androi 原声sqlite 操作
发布时间:2020-12-12 19:32:46 所属栏目:百科 来源:网络整理
导读:转载:http://www.thinksaas.cn/group/topic/83748/ http://www.cnblogs.com/zhangs1986/p/3744756.html http://blog.csdn.net/sgx425021234/article/details/9018387 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thundersoft.k
转载:http://www.thinksaas.cn/group/topic/83748/ http://www.cnblogs.com/zhangs1986/p/3744756.html http://blog.csdn.net/sgx425021234/article/details/9018387
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thundersoft.kids2/com.thundersoft.kids2.activity.MainActivity}: android.database.sqlite.SQLiteException: near "tabletb_contacts": syntax error (code 1):,while compiling: create tabletb_contacts(_idinteger primary key autoincrement,nametext not null,phonetext not null); 解决:SQL 语句出错 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thundersoft.kids2/com.thundersoft.kids2.activity.MainActivity}: android.database.sqlite.SQLiteException: near "tabletb_contacts": syntax error (code 1):,phonetext not null); <pre name="code" class="java">解决:SQL 语句出错java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thundersoft.kids2/com.thundersoft.kids2.activity.MainActivity}: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.thundersoft.kids2/databases/contacts_database解决:再次使用数据库时,没有打开数据库 update 关键字里没有 and!!,new String[]{contact.getName(),contact.getPhone(),String.valueOf(contact.getId())});正确:mDatabase.execSQL("update "+TABLE_NAME+" set name = ?,phone = ? where _id =?",String.valueOf(contact.getId())}); if(tmpList == null || tmpList.size() ==0){ Contact contactOne = new Contact("Zhangs","123456789"); Contact contactTwo = new Contact("Lis","456789123"); Contact contactThree = new Contact("Wangw","789456123"); simpleContactList = new ArrayList<Contact>(); simpleContactList.add(contactOne); simpleContactList.add(contactTwo); simpleContactList.add(contactThree); //插入 mDatabaseUtil.insertContactList(simpleContactList); //自动生成得ID 第一次没有读取到 simpleContactList = mDatabaseUtil.findAllContact(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |