Slide 10
Slide 10 text
10
Podstawowe zapytania
●
INSERT i SELECT
String INSERT = "INSERT INTO " + "EMPLOYEES" + " (name,
surname, age) VALUES (?, ?, ?)";
SQLiteStatement insertStatement = db.compileStatement(INSERT);
insertStatement.bindString(1, "scott");
insertStatement.bindString(2, "tiger");
insertStatement.bindLong(3, 666);
insertStatement.executeInsert();
Cursor cursor = db.query("EMPLOYEES", new String[] {"name",
"surname", "age"}, "name = ?", new String[] {"scott"}, null,
null, "age");
if (cursor.moveToFirst()) {
do {
Log.d("AS", cursor.getString(0) + " " +
cursor.getString(1) + ", " + cursor.getLong(2));
} while (cursor.moveToNext());
}
if (cursor != null && !cursor.isClosed()) cursor.close();