@Test public void fillFromCursor() { MatrixCursor cursor = new MatrixCursor(new String[] { "name", "count" }); cursor.addRow(new Object[] { "test", 5 }); cursor.moveToFirst(); Category category = new Category(cursor); assertEquals("test", category.name); assertEquals(5, category.numberArticles); }
@Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals(CategoryModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("count")) { this.numberArticles = cursor.getInt(i); } } }
Category implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals(CategoryModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("count")) { this.numberArticles = cursor.getInt(i); } } } }
Category implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals(CategoryModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("count")) { this.numberArticles = cursor.getInt(i); } } } Category();  Category(Cursor cursor); }
Category implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals(CategoryModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("count")) { this.numberArticles = cursor.getInt(i); } } } Category();  Category(Cursor cursor); @Override void fillFromCursor(Cursor cursor); }
Category implements DatabaseModel { @Override public void fillFromCursor(Cursor cursor) { for (int i = 0; i < cursor.getColumnCount(); i++) { String column = cursor.getColumnName(i); if (column.equals(CategoryModel.COLUMN_NAME)) { this.name = cursor.getString(i); } else if (column.equals("count")) { this.numberArticles = cursor.getInt(i); } } } Category();  Category(Cursor cursor); @Override void fillFromCursor(Cursor cursor); public String name; public int numberArticles; }