Я впервые использую базу данных ORMlite в своем приложении. Я взял ссылку из учебника, но вместо того, чтобы делать все точно так же, я не могу разрешить ошибку. Мой код ниже: -Создание базы данных с использованием orm
DatabaseHelper:
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static final String DATABASE_NAME = "qzeodemo.db";
private static final int DATABASE_VERSION = 1;
private Dao<ModifierDetails, Integer> itemsDao;
private Dao<ItemDetails, Integer> modifiersDao;
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION, R.raw.ormlite_config);
}
@Override
public void onCreate(SQLiteDatabase sqliteDatabase, ConnectionSource connectionSource) {
try {
// Create tables. This onCreate() method will be invoked only once of the application life time i.e. the first time when the application starts.
TableUtils.createTable(connectionSource,ItemDetails.class);
TableUtils.createTable(connectionSource,ModifierDetails.class);
} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Unable to create datbases", e);
}
}
@Override
public void onUpgrade(SQLiteDatabase sqliteDatabase, ConnectionSource connectionSource, int oldVer, int newVer) {
try {
// In case of change in database of next version of application, please increase the value of DATABASE_VERSION variable, then this method will be invoked
//automatically. Developer needs to handle the upgrade logic here, i.e. create a new table or a new column to an existing table, take the backups of the
// existing database etc.
TableUtils.dropTable(connectionSource, ItemDetails.class, true);
TableUtils.dropTable(connectionSource, ModifierDetails.class, true);
onCreate(sqliteDatabase, connectionSource);
} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Unable to upgrade database from version " + oldVer + " to new "
+ newVer, e);
}
}
// Create the getDao methods of all database tables to access those from android code.
// Insert, delete, read, update everything will be happened through DAOs
public Dao<ItemDetails,Integer> getItemDao() throws SQLException {
if (itemsDao == null) {
itemsDao = getDao(ItemDetails.class);
}
return itemsDao;
}
public Dao<ModifierDetails, Integer> getMofifierDao() throws SQLException {
if (modifiersDao == null) {
modifiersDao = getDao(ModifierDetails.class);
}
return modifiersDao;
}
}
линия, где я использую modifiersDao = getDao (ModifierDetails.class); дает ошибку
Ошибка: (76, 30) error: недопустимые предполагаемые типы для D; выведенный тип не соответствует объявлена связанным (ы) вывод: ДАО связан (ы): ДАО , где D, Т являются тип-переменные: D расширяет ДАО объявленные в методе getDao (класс) Т расширяет Объект объявлен в методе getDao (класс)
Пожалуйста, помогите :(
Привет, спасибо yaar .. я не могу поверить, что я делал такую большую ошибку, и это тоже s2pd ... может быть его фобией ORM или я должен сделать перерыв ..: D –
иногда лучше расслабиться, а затем вернуться к коду ... – AndroidEnthusiast