我想創建2個表這樣對嗎?
public class MyDatabaseHelper extends SQLiteOpenHelper {
private String CREATE_TABLE_USER = "create table USER(" + "username text,"
+ "usermima text," + ")";
private String CREATE_TABLE_STU = "create table STU(" + "id text,"
+ "name text," + "num text," + ")";
public MyDatabaseHelper(Context context, String name,
CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase arg0) {
arg0.execSQL(CREATE_TABLE_USER);
arg0.execSQL(CREATE_TABLE_STU);
}
我在MainActivity中
private MyDatabaseHelper myhelper;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myhelper = new MyDatabaseHelper(MainActivity.this, "UserDB.db", null, 1);
myhelper.getWritableDatabase();
可以用第一張表USER ,但是在第二個Activity中要怎麼才能對第二張表STU進行增刪改查操作呢 求幫忙
就你的需求
private String CREATE_TABLE_USER = "create table USER(" + "username text,"