File file=new File(getContext().getExternalFilesDir(null),"learn.db");
SQLiteDatabase database=SQLiteDatabase.openOrCreateDatabase(file,null);
Cursor tables=database.rawQuery("select name from sqlite_master where type='table' order by name",null);
names=new String[tables.getCount()-1];
int i=0;
while(tables.moveToNext()){
//第一个不需要,去掉,将查询的信息保存在数组里
if (i!=0){
names[i-1]=tables.getString(0);
}
i++;
}
tables.close();
sql = "select * from TableName where "+条件+" order by "+排序+" limit "+要显示多少条记录+" offset "+跳过多少条记录;
database.execSQL("UPDATE 表名 SET 字段名 = 值 WHERE ID = 6");
database.execSQL("DELETE FROM 表名 WHERE ID = 1");
database.execSQL("CREATE TABLE table_name (column1 CHAR(100),column2 CHAR(100))");
database.execSQL("CREATE TABLE IF NOT EXISTS user (number CHAR(100),password CHAR(100))");
database.execSQL(String.format("INSERT INTO english (name) VALUES (\"%s\")",data.getString(data.getColumnIndex("firstColumnName"))));
此例子是插入文本数据
向一个表中插入另一个表的数据
insert into 被插入表名 select from * where ......
Cursor cursor=database.rawQuery(String.format("select DISTINCT name from english"),null);
SELECT * FROM table ORDER BY RANDOM() limit 1