org.sqlite.database.sqlite.SQLiteDatabase Java Examples
The following examples show how to use
org.sqlite.database.sqlite.SQLiteDatabase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SQLiteContentProvider.java From SQLite with Apache License 2.0 | 6 votes |
@Nullable @Override public final Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteDatabase database = mSQLiteHelper.getWritableDatabase(); String table = getType(uri); if (TextUtils.isEmpty(table)) { throw new IllegalArgumentException("No such table to query"); } else { return database.query(table, projection, selection, selectionArgs, null, null, sortOrder); } }
Example #2
Source File: SQLiteContentProvider.java From SQLite with Apache License 2.0 | 6 votes |
@Override public final int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) { SQLiteDatabase database = mSQLiteHelper.getWritableDatabase(); String table = getType(uri); if (TextUtils.isEmpty(table)) { throw new IllegalArgumentException("No such table to insert"); } else { int numInserted = 0; database.beginTransaction(); try { for (ContentValues contentValues : values) { long id = database.insertWithOnConflict(table, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE); if (id > 0) { numInserted++; } } database.setTransactionSuccessful(); } finally { database.endTransaction(); } return numInserted; } }
Example #3
Source File: RequestTable.java From AndroidSchool with Apache License 2.0 | 5 votes |
@Override public void onCreate(@NonNull SQLiteDatabase database) { TableBuilder.create(this) .textColumn(REQUEST) .textColumn(STATUS) .textColumn(ERROR) .primaryKey(REQUEST) .execute(database); }
Example #4
Source File: ExtraUtils.java From squidb with Apache License 2.0 | 5 votes |
/** * Utility method to run the query on the db and return the value in the * first column of the first row. */ public static long longForQuery( SQLiteDatabase db, String query, String[] selectionArgs ) { SQLiteStatement prog = db.compileStatement(query); try { return longForQuery(prog, selectionArgs); } finally { prog.close(); } }
Example #5
Source File: TestReactiveDatabase.java From squidb with Apache License 2.0 | 5 votes |
@Override protected void onConfigure(ISQLiteDatabase db) { /** @see AttachDetachTest#testAttacherInTransactionOnAnotherThread() */ Object wrappedObject = db.getWrappedObject(); if (wrappedObject instanceof SQLiteDatabase) { ((SQLiteDatabase) wrappedObject).enableWriteAheadLogging(); } else if (wrappedObject instanceof android.database.sqlite.SQLiteDatabase) { ((android.database.sqlite.SQLiteDatabase) wrappedObject).enableWriteAheadLogging(); } }
Example #6
Source File: JUnitTestTable.java From SQLite with Apache License 2.0 | 5 votes |
@Override public void onCreate(@NonNull SQLiteDatabase database) { TableBuilder.create(this) .intColumn(ID) .realColumn(RATING) .textColumn(TEXT) .primaryKey(ID) .execute(database); }
Example #7
Source File: TestTable.java From SQLite with Apache License 2.0 | 5 votes |
@Override public void onCreate(@NonNull SQLiteDatabase database) { TableBuilder.create(this) .intColumn(ID) .realColumn(RATING) .textColumn(TEXT) .primaryKey(ID) .execute(database); }
Example #8
Source File: SQLiteHelper.java From SQLite with Apache License 2.0 | 5 votes |
@Override public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) { for (Table table : mSchema) { if (oldVersion < newVersion && newVersion <= table.getLastUpgradeVersion()) { table.onUpgrade(database); } } }
Example #9
Source File: SQLiteContentProvider.java From SQLite with Apache License 2.0 | 5 votes |
@Override public final int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) { SQLiteDatabase database = mSQLiteHelper.getWritableDatabase(); String table = getType(uri); if (TextUtils.isEmpty(table)) { throw new IllegalArgumentException("No such table to update"); } else { return database.update(table, values, selection, selectionArgs); } }
Example #10
Source File: SQLiteContentProvider.java From SQLite with Apache License 2.0 | 5 votes |
@Override public final int delete(@NonNull Uri uri, String selection, String[] selectionArgs) { SQLiteDatabase database = mSQLiteHelper.getWritableDatabase(); String table = getType(uri); if (TextUtils.isEmpty(table)) { throw new IllegalArgumentException("No such table to delete"); } else { return database.delete(table, selection, selectionArgs); } }
Example #11
Source File: SQLiteContentProvider.java From SQLite with Apache License 2.0 | 5 votes |
@NonNull @Override public final Uri insert(@NonNull Uri uri, ContentValues values) { SQLiteDatabase database = mSQLiteHelper.getWritableDatabase(); String table = getType(uri); if (TextUtils.isEmpty(table)) { throw new IllegalArgumentException("No such table to insert"); } else { long id = database.insertWithOnConflict(table, null, values, SQLiteDatabase.CONFLICT_REPLACE); return ContentUris.withAppendedId(uri, id); } }
Example #12
Source File: CityTable.java From AndroidSchool with Apache License 2.0 | 5 votes |
@Override public void onCreate(@NonNull SQLiteDatabase database) { TableBuilder.create(this) .textColumn(CITY_NAME) .textColumn(WEATHER) .textColumn(MAIN) .textColumn(WIND) .execute(database); }
Example #13
Source File: WeatherCityTable.java From AndroidSchool with Apache License 2.0 | 5 votes |
@Override public void onCreate(@NonNull SQLiteDatabase database) { TableBuilder.create(this) .textColumn(CITY_ID) .textColumn(CITY_NAME) .primaryKey(CITY_ID) .execute(database); }
Example #14
Source File: CityTable.java From AndroidSchool with Apache License 2.0 | 5 votes |
@Override public void onCreate(@NonNull SQLiteDatabase database) { TableBuilder.create(this) .textColumn(CITY_NAME) .textColumn(WEATHER) .textColumn(MAIN) .textColumn(WIND) .execute(database); }
Example #15
Source File: SQLiteBindingsOpenHelper.java From squidb with Apache License 2.0 | 4 votes |
@Override public void onConfigure(SQLiteDatabase db) { delegate.onConfigure(new SQLiteBindingsAdapter(db)); }
Example #16
Source File: SQLiteBindingsOpenHelper.java From squidb with Apache License 2.0 | 4 votes |
@Override public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { delegate.onDowngrade(new SQLiteBindingsAdapter(db), oldVersion, newVersion); }
Example #17
Source File: SQLiteBindingsOpenHelper.java From squidb with Apache License 2.0 | 4 votes |
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { delegate.onUpgrade(new SQLiteBindingsAdapter(db), oldVersion, newVersion); }
Example #18
Source File: DatabaseHelper.java From imsdk-android with MIT License | 4 votes |
@Override public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { super.onDowngrade(db, oldVersion, newVersion); }
Example #19
Source File: SQLiteBindingsOpenHelper.java From squidb with Apache License 2.0 | 4 votes |
@Override public void onCreate(SQLiteDatabase db) { delegate.onCreate(new SQLiteBindingsAdapter(db)); }
Example #20
Source File: SQLiteBindingsOpenHelper.java From squidb with Apache License 2.0 | 4 votes |
@Override public ISQLiteDatabase openForWriting() { SQLiteDatabase database = super.getWritableDatabase(); return new SQLiteBindingsAdapter(database); }
Example #21
Source File: SQLiteBindingsAdapter.java From squidb with Apache License 2.0 | 4 votes |
@Override public SQLiteDatabase getWrappedObject() { return db; }
Example #22
Source File: SQLiteBindingsAdapter.java From squidb with Apache License 2.0 | 4 votes |
public SQLiteBindingsAdapter(SQLiteDatabase db) { if (db == null) { throw new NullPointerException("Can't create SQLiteDatabaseAdapter with a null SQLiteDatabase"); } this.db = db; }
Example #23
Source File: SQLiteBindingsCursorFactory.java From squidb with Apache License 2.0 | 4 votes |
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { bindArgumentsToProgram(query, sqlArgs); return new SQLiteCursor(masterQuery, editTable, query); }
Example #24
Source File: SQLiteBindingsOpenHelper.java From squidb with Apache License 2.0 | 4 votes |
@Override public void onOpen(SQLiteDatabase db) { delegate.onOpen(new SQLiteBindingsAdapter(db)); }
Example #25
Source File: ContentProviderErrorsTest.java From SQLite with Apache License 2.0 | 4 votes |
@Override public void onCreate(@NonNull SQLiteDatabase database) { throw new RuntimeException("Stub!"); }
Example #26
Source File: BaseTable.java From SQLite with Apache License 2.0 | 4 votes |
@Override public void onUpgrade(@NonNull SQLiteDatabase database) { database.execSQL("DROP TABLE IF EXISTS " + getTableName()); onCreate(database); }
Example #27
Source File: SQLiteHelper.java From SQLite with Apache License 2.0 | 4 votes |
@Override public void onCreate(SQLiteDatabase database) { for (Table table : mSchema) { table.onCreate(database); } }
Example #28
Source File: TableBuilder.java From SQLite with Apache License 2.0 | 4 votes |
public void execute(@NonNull SQLiteDatabase database) { database.execSQL(buildSQL()); }
Example #29
Source File: DatabaseErrorHandler.java From squidb with Apache License 2.0 | 2 votes |
/** * defines the method to be invoked when database corruption is detected. * @param dbObj the {@link SQLiteDatabase} object representing the database on which corruption * is detected. */ void onCorruption(SQLiteDatabase dbObj);
Example #30
Source File: AndroidBindingsSQLiteDatabase.java From geopackage-android with MIT License | 2 votes |
/** * Get the SQLite database connection * * @return connection */ public SQLiteDatabase getDb() { return db; }