本文主要是介绍安卓中对SQLite数据库的增删改查,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
第一步:编写一个java Bean
package com.itfom.entity;public class Person {private String name;private int age;private String phone;public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}//创建构造函数public Person(){}public Person(String name,int age,String phone){this.name=name;this.age=age;this.phone=phone;}//重写toString@Overridepublic String toString() {return "姓名:"+name+"年龄:"+age+"电话:"+phone+"\n";}
}
第二步:创建数据库
package com.itfom.helper;import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;public class OpenHelper extends SQLiteOpenHelper {public OpenHelper(Context context) {//这三个参数分别为上下文对象,数据库名称,游标,版本号super(context, "xsc.db", null, 1);}@Overridepublic void onCreate(SQLiteDa
这篇关于安卓中对SQLite数据库的增删改查的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!