前端之家收集整理的这篇文章主要介绍了
Andoid Sqlite 增查,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
sqliteDatabase demosqlite = this.openOrCreateDatabase("sqllite_demo.db",Context.MODE_PRIVATE,null);
//String sql = "Create table test1(id int)";
// for(int i = 0;i<10;i++){
// String sql = "insert into test1(id) values("+i+")";
// demosqlite.execsql(sql);
// }
//
Cursor cursor = demosqlite.rawQuery("select * from test1",null);
int i = 0;
if(cursor != null){
if(cursor.moveToFirst()){
do{
System.out.println(cursor.getString(0));
//i++;
}while(cursor.moveToNext());
}
}