在SQLite中直接跑SQL语句
private void initDatabase()
{
mdb = this.openOrCreateDatabase("dbfile", 0, null);
String sql_create = "create table test (id int, name TEXT)";
mdb.execSQL(sql_create);
String sql_insert = "insert into test(id, name) values(3, 'name3')";
mdb.execSQL(sql_insert);
}
private String getName()
{
String name = null;
Cursor cur = mdb.rawQuery("select * from test", null);
cur.moveToFirst();
while (!cur.isLast())
{
name = name + cur.getString(1)+ "\r\n";
cur.moveToNext();
}
return name;
}