Android中数据库的创建
• 数据库类:SQLite Database
• 数据库帮助类:SQLiteOpenHelper
方法一
• db = SQLiteDatabase.openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null)
方法二
• db = getContext().openOrCreateDatabase (DATABASE NAME, Context.MODE PRIVATE, null)
方法三
• db = SQLiteOpenHelper.getWritableDatabase()
• db = SQLiteOpenHelper.getReableDatabase()
执行SQL语句,这里是直接执行
• String sq| = "insert into tableName values (" 小华", "111");";
• db.execSQL(sql);
Android中封装好的SQL语句执行方法
•增加一条数据 db.insert(TABLE_ NAME, null, values);
•删除一条数据 db.delete(TABLE_ NAME, selection, selectionArgs)
•修改一条数据 db.update(TABLE_ NAME,values, selection,selectionArgs);
•查询一条数据 db.query(
TABLE_NAME, // The table to query
projection, //The array of columns to return (pass null to get all)
selection, // The columns for the WHERE clause
selectionArgs, // The values for the WHERE clause
null, // don't group the rows
null, // don't filter by row groups
sortOrder // The sort order
);
标签:总结,selection,NAME,每日,db,23.3,TABLE,values,null From: https://www.cnblogs.com/laobing6214/p/17176903.html