Android 数据库 SQLiteOpenHelper
程序员文章站
2022-04-14 20:29:53
public class DbOpenHelper extends SQLiteOpenHelper { private static String name = "test.db"; /* 数据库名称 */ private static int version = 1; /* 数据库版本号 */ ... ......
public class dbopenhelper extends sqliteopenhelper { private static string name = "test.db"; /* 数据库名称 */ private static int version = 1; /* 数据库版本号 */ public dbopenhelper(context context) { super(context, name, null, version); // todo auto-generated constructor stub } @override public void oncreate(sqlitedatabase db) { // todo auto-generated method stub string sql = "create table person(id integer primary key autoincrement, name varchar(64))"; db.execsql(sql); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // todo auto-generated method stub } }
private button button; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button = (button) this.findviewbyid(r.id.button); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub dbopenhelper dbopenhelper = new dbopenhelper(mainactivity.this); dbopenhelper.getwritabledatabase(); } }); }
上一篇: Spring HttpInvoker 从实战到源码追溯
下一篇: fso的一些特殊功能