Мое приложение написано на Kotlin, и я также использовал сырой SQLite и Room, но оба они дают мне следующее исключение при попытке сохранить элементы.
Entity
@Entity(tableName = "asteroids")
data class CachedAsteroid(
@PrimaryKey val id: Int,
var name: String,
@TypeConverters(CachedEstimatedDiameterConverter::class)
@Embedded
var estimatedDiameter: CachedEstimatedDiameter,
var isPotentiallyHazardousAsteroid: Boolean,
var absoluteMagnitudeH: Float,
@TypeConverters(CachedCloseApproachDataConverter::class)
@Embedded
var closeApproachData: CachedCloseApproachData
)
DAO
@Dao
interface AsteroidDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAsteroids(asteroids: List<CachedAsteroid>)
@Query("SELECT * FROM asteroids WHERE (closeApproachDate BETWEEN :startDate AND :endDate)")
fun getAsteroids(startDate: Date, endDate: Date): Single<List<CachedAsteroid>>
@Query("SELECT * FROM asteroids WHERE name = :asteroidName")
fun getAsteroidByName(asteroidName: String): Single<CachedAsteroid>
@Query("SELECT COUNT(id) FROM asteroids")
fun storedAsteroidsCount(): Single<Int>
}
Исключение
Caused by: android.content.res.Resources$NotFoundException: Resource
ID #0x10e0060 at
android.content.res.Resources.getValue(Resources.java:1233) at
android.content.res.Resources.getInteger(Resources.java:989) at
android.database.CursorWindow.__constructor__(CursorWindow.java:103)
at android.database.CursorWindow.<init>(CursorWindow.java) at
android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
at
android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:139)
at
android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
at
android.database.AbstractCursor.moveToPosition(AbstractCursor.java:197)
at
android.database.AbstractCursor.moveToFirst(AbstractCursor.java:237)
at
androidx.room.RoomOpenHelper.hasRoomMasterTable(RoomOpenHelper.java:156)
at
androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.java:124)
at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:116) at
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:151)
at
android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:266)
at
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:96)
at
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54)
at androidx.room.RoomDatabase.beginTransaction(RoomDatabase.java:257)
at
com.github.meness.asteroids.cache.AsteroidCacheImpl$saveAsteroids$1.call(AsteroidCacheImpl.kt:33)
at
com.github.meness.asteroids.cache.AsteroidCacheImpl$saveAsteroids$1.call(AsteroidCacheImpl.kt:17)
at
io.reactivex.internal.operators.completable.CompletableDefer.subscribeActual(CompletableDefer.java:36)
at io.reactivex.Completable.subscribe(Completable.java:2171) at
io.reactivex.Completable.test(Completable.java:2610)
Дополнительная информация
- minSdk : 21
- targetSdk : 28
- compileSdk : 28
- Версия номера : 2.0.0