当前位置: 代码迷 >> SQL >> 在SQLite中直接跑SQL话语
  详细解决方案

在SQLite中直接跑SQL话语

热度:9   发布时间:2016-05-05 13:32:36.0
在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;
    }
  相关解决方案