1、可以在创建表之前判断,这样就不会重新创建,create table if not exists Student(name text primary key, code integer); 比平时多了if not exists
2、
Cursor cursor = db.rawQuery("select name from sqlite_master where type='table';", null); while(cursor.moveToNext()){ //遍历出表名 String name = cursor.getString(0); Log.i("System.out", name); }
3、
String sql = "select count(*) as c from sqlite_master where type ='table' and name ='Student';"; cursor = db.rawQuery(sql, null); if(cursor.moveToNext()){ int count = cursor.getInt(0); if(count>0){ result = true; } }