// DbConn conn = new DbConn(MainActivity.this,"hellodb",null,1);
// conn.createTable("worldtb");
package com.oschina.osmf; import android.content.Context; import android.database.sqlite.sqliteDatabase; import android.database.sqlite.sqliteDatabase.CursorFactory; import android.database.sqlite.sqliteOpenHelper; import android.util.Log; public class DbConn extends sqliteOpenHelper{ public DbConn(Context context,String name,CursorFactory factory,int version) { super(context,name,factory,version); } @Override public void onCreate(sqliteDatabase db) { } @Override public void onUpgrade(sqliteDatabase db,int oldVersion,int newVersion) { } public void createTable(String tableName) { sqliteDatabase db = this.getWritableDatabase(); String sql = "create table if not exists "+tableName+"(id integer primary key,name varchar)"; db.execsql(sql); Log.i("test","创建表成功"); } public void selectTable(String tableName) { } }
原文链接:https://www.f2er.com/sqlite/200629.html