use of android.database.sqlite.SQLiteOpenHelper in project storio by pushtorefresh.
the class DefaultStorIOSQLiteTest method defaultSchedulerReturnsSpecifiedScheduler.
@Test
public void defaultSchedulerReturnsSpecifiedScheduler() {
Scheduler scheduler = mock(Scheduler.class);
StorIOSQLite storIOSQLite = DefaultStorIOSQLite.builder().sqliteOpenHelper(mock(SQLiteOpenHelper.class)).defaultScheduler(scheduler).build();
assertThat(storIOSQLite.defaultScheduler()).isSameAs(scheduler);
}
use of android.database.sqlite.SQLiteOpenHelper in project AndroidSDK-RecipeBook by gabu.
the class Recipe084 method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SQLiteOpenHelper helper = new MySQLiteOpenHelper(getApplicationContext());
SQLiteDatabase db = helper.getWritableDatabase();
// dbを使った処理
db.close();
}
use of android.database.sqlite.SQLiteOpenHelper in project zxingfragmentlib by mitoyarzun.
the class HistoryManager method trimHistory.
public void trimHistory() {
SQLiteOpenHelper helper = new DBHelper(activity);
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = helper.getWritableDatabase();
cursor = db.query(DBHelper.TABLE_NAME, ID_COL_PROJECTION, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
cursor.move(MAX_ITEMS);
while (cursor.moveToNext()) {
String id = cursor.getString(0);
Log.i(TAG, "Deleting scan history ID " + id);
db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + id, null);
}
} catch (SQLiteException sqle) {
// We're seeing an error here when called in CaptureActivity.onCreate() in rare cases
// and don't understand it. First theory is that it's transient so can be safely ignored.
Log.w(TAG, sqle);
// continue
} finally {
close(cursor, db);
}
}
use of android.database.sqlite.SQLiteOpenHelper in project zxingfragmentlib by mitoyarzun.
the class HistoryManager method buildHistoryItems.
public List<HistoryItem> buildHistoryItems() {
SQLiteOpenHelper helper = new DBHelper(activity);
List<HistoryItem> items = new ArrayList<>();
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = helper.getReadableDatabase();
cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
while (cursor.moveToNext()) {
String text = cursor.getString(0);
String display = cursor.getString(1);
String format = cursor.getString(2);
long timestamp = cursor.getLong(3);
String details = cursor.getString(4);
Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
items.add(new HistoryItem(result, display, details));
}
} finally {
close(cursor, db);
}
return items;
}
use of android.database.sqlite.SQLiteOpenHelper in project zxingfragmentlib by mitoyarzun.
the class HistoryManager method hasHistoryItems.
public boolean hasHistoryItems() {
SQLiteOpenHelper helper = new DBHelper(activity);
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = helper.getReadableDatabase();
cursor = db.query(DBHelper.TABLE_NAME, COUNT_COLUMN, null, null, null, null, null);
cursor.moveToFirst();
return cursor.getInt(0) > 0;
} finally {
close(cursor, db);
}
}
Aggregations