Lines Matching refs:database

4 import android.database.Cursor;
5 import android.database.sqlite.SQLiteDatabase;
24 protected SQLiteDatabase database;
29 database = SQLiteDatabase.openDatabase("path", null, 0);
30 shDatabase = Robolectric.shadowOf(database);
31 database.execSQL("CREATE TABLE table_name (\n" +
39 database.execSQL("CREATE TABLE rawtable (\n" +
47 database.execSQL("CREATE TABLE exectable (\n" +
63 database.insert("rawtable", null, values);
72 database.insert("rawtable", null, values2);
78 database.close();
91 database.insert("table_name", null, values);
93 Cursor cursor = database.query("table_name", new String[]{"second_column", "first_column"}, null, null, null, null, null);
114 database.insert("table_name", null, values);
116 Cursor cursor = database.rawQuery("select second_column, first_column from table_name", null);
127 @Test(expected = android.database.SQLException.class)
130 database.insertOrThrow("table_name", null, new ContentValues());
140 database.insertOrThrow("table_name", null, values);
142 Cursor cursor = database.rawQuery("select second_column, first_column from table_name", null);
152 database.rawQuery("select second_column, first_column from rawtable WHERE `id` = ?", new String[]{null});
157 database.rawQuery("select second_column, first_column from rawtable", new String[]{null});
162 Cursor cursor = database.rawQuery("select second_column, first_column from rawtable WHERE `id` = ?", new String[]{"1"});
168 Cursor cursor = database.rawQuery("select second_column, first_column from rawtable", null);
174 Cursor cursor = database.rawQuery("select second_column, first_column from rawtable", new String[]{});
218 Cursor cursor = database.rawQuery("select second_column, first_column from rawtable WHERE `id` = ?", null);
224 Cursor cursor = database.rawQuery("select second_column, first_column from rawtable WHERE `id` = ?", new String[]{});
227 @Test(expected = android.database.sqlite.SQLiteException.class)
229 Cursor cursor = database.rawQuery("select second_column, first_column from rawtable", new String[]{"1"});
236 assertEquals(-1, database.insert("table_that_doesnt_exist", null, values));
242 Cursor cursor = database.query("table_name", new String[]{"second_column", "first_column"}, null, null, null, null, null);
252 long id = database.insert("table_name", null, values);
262 long key = database.insertWithOnConflict("table_name", null, values, SQLiteDatabase.CONFLICT_IGNORE);
273 Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);
286 Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);
300 Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);
318 int deleted = database.delete("table_name", "id=1234", null);
328 int deleted = database.delete("table_name", "id=5678", null);
339 int deleted = database.delete("table_name", "1", null);
351 database.execSQL("INSERT INTO table_name (id, name) VALUES(1234, 'Chuck');");
353 statement = shadowOf(database).getConnection().createStatement();
358 statement = shadowOf(database).getConnection().createStatement();
370 database.execSQL("CREATE TABLE `routine` (`id` INTEGER PRIMARY KEY AUTOINCREMENT , `name` VARCHAR , `lastUsed` INTEGER DEFAULT 0 , UNIQUE (`name`)) ", new Object[]{});
371 database.execSQL("INSERT INTO `routine` (`name` ,`lastUsed` ) VALUES (?,?)", new Object[]{"Leg Press", 0});
372 database.execSQL("INSERT INTO `routine` (`name` ,`lastUsed` ) VALUES (?,?)", new Object[]{"Bench Press", 1});
374 statement = shadowOf(database).getConnection().createStatement();
379 statement = shadowOf(database).getConnection().createStatement();
391 @Test(expected = android.database.SQLException.class)
393 database.execSQL("INSERT INTO table_name;"); // invalid SQL
398 database.execSQL("insert into exectable (first_column) values (?);", null);
403 database.execSQL("insert into exectable (first_column) values ('sdfsfs');", null);
408 //TODO: make this throw android.database.SQLException.class
409 database.execSQL("insert into exectable (first_column) values ('kjhk');", new String[]{"xxxx"});
414 //TODO: make this throw android.database.SQLException.class
415 database.execSQL("insert into exectable (first_column) values ('kdfd');", new String[]{null});
420 database.execSQL("insert into exectable (first_column) values ('eff');", new String[]{});
427 database.execSQL("insert into exectable (first_column, name) values (?,?);", new String[]{null, name});
429 Cursor cursor = database.rawQuery("select * from exectable WHERE `name` = ?", new String[]{name});
442 database.delete("exectable", null, null);
444 Cursor cursor = database.rawQuery("select * from exectable", null);
448 database.execSQL("insert into exectable (first_column) values (?);", new String[]{});
449 Cursor cursor2 = database.rawQuery("select * from exectable", new String[]{null});
457 database.execSQL("CREATE TABLE auto_table (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255));");
462 long key = database.insert("auto_table", null, values);
465 long key2 = database.insert("auto_table", null, values);
471 database.close();
473 database.execSQL("INSERT INTO table_name (id, name) VALUES(1234, 'Chuck');");
478 assertThat(database.isOpen(), equalTo(true));
479 database.close();
480 assertThat(database.isOpen(), equalTo(false));
485 database.execSQL("INSERT INTO table_name(big_int) VALUES(1234567890123456789);");
486 Cursor cursor = database.query("table_name", new String[]{"big_int"}, null, null, null, null, null);
494 database.beginTransaction();
496 database.execSQL("INSERT INTO table_name (id, name) VALUES(1234, 'Chuck');");
498 database.setTransactionSuccessful();
500 database.endTransaction();
503 Statement statement = shadowOf(database).getConnection().createStatement();
512 database.beginTransaction();
515 database.execSQL("INSERT INTO table_name (id, name) VALUES(1234, 'Chuck');");
517 Statement statement = shadowOf(database).getConnection().createStatement();
526 database.endTransaction();
528 statement = shadowOf(database).getConnection().createStatement();
538 database.beginTransaction();
539 database.setTransactionSuccessful();
541 database.setTransactionSuccessful();
550 assertThat( database.inTransaction(), equalTo(false) );
551 database.beginTransaction();
552 assertThat( database.inTransaction(), equalTo(true) );
553 database.endTransaction();
554 assertThat( database.inTransaction(), equalTo(false) );
569 return database.insert("table_name", null, values);
575 return database.update("table_name", values, "id=" + id, null);
581 return database.update("table_name", values, null, null);
595 Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);
602 Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);