androiddatabaseormandroid-sqliteactiveandroid

ReActiveAndroid - Database info referenced not found


I want replace old DB codes with ReActiveAndroid But there is an error for all operations

As mentioned in document, i have these classes :

Database Class

@Database(name = "MyDatabase", version = 1)
public class MyDatabase {
}

Application Class

DatabaseConfig appDatabase = new DatabaseConfig.Builder(MyDatabase.class)
            .build();

ReActiveAndroid.init(new ReActiveConfig.Builder(this)
            .addDatabaseConfigs(appDatabase)
            .build());

Model Class

@Table(database = MyDatabase.class)
public class User extends Model {
    ...
}

Insert Code

User user = new User();
user.id = id;
user.name = name;
user.save();

I have this error :

java.lang.IllegalArgumentException: Database info referenced with table ir.hatamiarash.app.models.User not found

Are there any settings I've missed?


Solution

  • True, but the reason I chose ReactiveAndroid is to migrate from ActiveAndroid. Realm doesn't use SQLite which means the migration process would be more involved.

    I found how to fix this problem:

    DatabaseConfig appDatabase = new DatabaseConfig.Builder(AppDatabase.class) .addModelClasses(LogEntry.class) .addMigrations(AppDatabase.MIGRATION_16_17) .build();

    You have to call addModelClasses. There is also some documentation that helped with subsequent errors that cropped up: https://imangazalievm.gitbooks.io/reactiveandroid/migration-from-activeandroid.html