@Test public void testGetAllData() throws IOException{ DatabaseHelper<Data, Batch<Data>> databaseHelper; Context context; GsonSerializationStrategy<Data, Batch<Data>> gsonSerializationStrategy; gsonSerializationStrategy = new GsonSerializationStrategy<>(); gsonSerializationStrategy.build(); context = RuntimeEnvironment.application; databaseHelper = new DatabaseHelper<>(gsonSerializationStrategy, "test", context); Collection<Data> dataArrayList = Utils.fakeCollection(5); databaseHelper.addData(dataArrayList); assertEquals(databaseHelper.getAllData(), dataArrayList); }
public Collection<E> getAllData() throws IOException { ArrayList<E> allEventData = new ArrayList<>(); SQLiteDatabase db = getWritableDatabase(); Cursor cursor = db.query(TABLE_EVENT_DATA, new String[]{KEY_DATA}, null, null, null, null, null); if (cursor.moveToFirst()) { do { E event = serializationStrategy.deserializeData(cursor.getBlob(0)); allEventData.add(event); } while (cursor.moveToNext()); } cursor.close(); return allEventData; }
DatabaseHelper extends SQLiteOpenHelper { public Collection<E> getAllData() throws IOException { ArrayList<E> allEventData = new ArrayList<>(); SQLiteDatabase db = getWritableDatabase(); Cursor cursor = db.query(TABLE_EVENT_DATA, new String[]{KEY_DATA}, null, null, null, null, null); if (cursor.moveToFirst()) { do { E event = serializationStrategy.deserializeData(cursor.getBlob(0)); allEventData.add(event); } while (cursor.moveToNext()); } cursor.close(); return allEventData; } }
DatabaseHelper extends SQLiteOpenHelper { public Collection<E> getAllData() throws IOException { ArrayList<E> allEventData = new ArrayList<>(); SQLiteDatabase db = getWritableDatabase(); Cursor cursor = db.query(TABLE_EVENT_DATA, new String[]{KEY_DATA}, null, null, null, null, null); if (cursor.moveToFirst()) { do { E event = serializationStrategy.deserializeData(cursor.getBlob(0)); allEventData.add(event); } while (cursor.moveToNext()); } cursor.close(); return allEventData; } DatabaseHelper(SerializationStrategy<E, T> serializationStrategy, String databaseName, Context context); }
DatabaseHelper extends SQLiteOpenHelper { public Collection<E> getAllData() throws IOException { ArrayList<E> allEventData = new ArrayList<>(); SQLiteDatabase db = getWritableDatabase(); Cursor cursor = db.query(TABLE_EVENT_DATA, new String[]{KEY_DATA}, null, null, null, null, null); if (cursor.moveToFirst()) { do { E event = serializationStrategy.deserializeData(cursor.getBlob(0)); allEventData.add(event); } while (cursor.moveToNext()); } cursor.close(); return allEventData; } DatabaseHelper(SerializationStrategy<E, T> serializationStrategy, String databaseName, Context context); @Override void onCreate(SQLiteDatabase db); @Override void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); void addData(Collection<E> dataCollection); Collection<E> getAllData(); void deleteDataList(Collection<E> dataCollection); void deleteAll(); boolean isDataInDB(String id); }
DatabaseHelper extends SQLiteOpenHelper { public Collection<E> getAllData() throws IOException { ArrayList<E> allEventData = new ArrayList<>(); SQLiteDatabase db = getWritableDatabase(); Cursor cursor = db.query(TABLE_EVENT_DATA, new String[]{KEY_DATA}, null, null, null, null, null); if (cursor.moveToFirst()) { do { E event = serializationStrategy.deserializeData(cursor.getBlob(0)); allEventData.add(event); } while (cursor.moveToNext()); } cursor.close(); return allEventData; } DatabaseHelper(SerializationStrategy<E, T> serializationStrategy, String databaseName, Context context); @Override void onCreate(SQLiteDatabase db); @Override void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); void addData(Collection<E> dataCollection); Collection<E> getAllData(); void deleteDataList(Collection<E> dataCollection); void deleteAll(); boolean isDataInDB(String id);  }