Android开发教程之--sql语句一、创建/删除表Stringsql=Createtable
Android开发教程之--sql语句
一、创建/删除表
String sql="Create table "+TABLE_NAME+"("+FIELD_ID+" integer primary key autoincrement," +FIELD_TITLE+" text );";db.execSQL(sql);String sql=" DROP TABLE IF EXISTS "+TABLE_NAME;db.execSQL(sql);
二、查询
从表中查询数据(in)
SELECT * FROM meta where media_id in (1,2,9);
三、插入
SQLiteDatabase db=this.getWritableDatabase();ContentValues cv=new ContentValues(); cv.put(FIELD_TITLE, Title);long row=db.insert(TABLE_NAME, null, cv);
四、更新
SQLiteDatabase db=this.getWritableDatabase();String where=FIELD_ID+"= ";String[] whereValue={Integer.toString(id)};ContentValues cv=new ContentValues(); cv.put(FIELD_TITLE, Title);db.update(TABLE_NAME, cv, where, whereValue);
五、删除
SQLiteDatabase db=this.getWritableDatabase();String where=FIELD_ID+"= ";String[] whereValue={Integer.toString(id)};db.delete(TABLE_NAME, where, whereValue);
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
