Questions tagged [android-room]

For questions related to Android Room Persistence Library (which is a part of Android Architecture Components)

Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.

6786 questions
538
votes
13 answers

Room - Schema export directory is not provided to the annotation processor so we cannot export the schema

I am using Android Database Component Room I've configured everything, but when I compile, Android Studio gives me this warning: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either…
Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
327
votes
9 answers

How to make primary key as autoincrement for Room Persistence lib

I am creating an Entity (Room Persistence Library) class Food, where I want to make foodId as autoincrement. @Entity class Food(var foodName: String, var foodDesc: String, var protein: Double, var carbs: Double, var fat: Double) { @PrimaryKey …
Sachin Chandil
  • 17,133
  • 8
  • 47
  • 65
272
votes
9 answers

Room persistance library. Delete all

How can I delete all entries on specific table using Room Persistence Library? I need to drop table, but I cannot to find any information how to do this. Only when database is migrating or to load all entries and delete them :)
Sirelon
  • 6,446
  • 5
  • 26
  • 30
256
votes
32 answers

Android room persistent: AppDatabase_Impl does not exist

My app database class @Database(entities = {Detail.class}, version = Constant.DATABASE_VERSION) public abstract class AppDatabase extends RoomDatabase { private static AppDatabase INSTANCE; public abstract FavoritesDao favoritesDao(); …
pratik deshai
  • 2,770
  • 2
  • 11
  • 13
229
votes
8 answers

Android Room - Get the id of new inserted row with auto-generate

This is how I am inserting data into database using Room Persistence Library: Entity: @Entity class User { @PrimaryKey(autoGenerate = true) public int id; //... } Data access object: @Dao public interface UserDao{ @Insert(onConflict…
SpiralDev
  • 7,011
  • 5
  • 28
  • 42
225
votes
24 answers

Android Room - simple select query - Cannot access database on the main thread

I am trying a sample with Room Persistence Library. I created an Entity: @Entity public class Agent { @PrimaryKey public String guid; public String name; public String email; public String password; public String phone; …
Devarshi
  • 16,440
  • 13
  • 72
  • 125
204
votes
8 answers

Update some specific field of an entity in android Room

I am using android room persistence library for my new project. I want to update some field of table. I have tried like in my Dao - // Method 1: @Dao public interface TourDao { @Update int updateTour(Tour tour); } But when I try to update…
Rasel
  • 5,488
  • 3
  • 30
  • 39
197
votes
14 answers

How to get rid of Incremental annotation processing requested warning?

I have just started using android development and trying to use Room library. Since yesterday I am facing this warning message w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not…
Shax
  • 4,207
  • 10
  • 46
  • 62
166
votes
4 answers

Android Room - Select query with LIKE

I'm trying to make a query to search all objects whose names contain text: @Query("SELECT * FROM hamster WHERE name LIKE %:arg0%") fun loadHamsters(search: String?): Flowable> Messages: Error:no viable alternative at input 'SELECT *…
Denis Buzmakov
  • 1,662
  • 2
  • 10
  • 8
150
votes
23 answers

Room cannot verify the data integrity

I am getting this error while running program with Room Database Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. It seems we…
Ravi
  • 34,851
  • 21
  • 122
  • 183
146
votes
7 answers

Room database migration if only new table is added

Let't assume, I have a simple Room database: @Database(entities = {User.class}, version = 1) abstract class AppDatabase extends RoomDatabase { public abstract Dao getDao(); } Now, I'm adding a new entity: Pet and bumping version to…
142
votes
21 answers

Android Room Database: How to handle Arraylist in an Entity?

I just implemented Room for offline data saving. But in an Entity class, I am getting the following error: Error:(27, 30) error: Cannot figure out how to save this field into database. You can consider adding a type converter for it. And the class…
Tushar Gogna
  • 4,963
  • 6
  • 31
  • 42
141
votes
6 answers

Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64

I am using Android Studio [Android Studio Arctic Fox | 2020.3.1 Patch 1] My room library version is [2.3.0] Used Gradle version [7.0.1] Also added kapt 'org.xerial:sqlite-jdbc:3.36.0.1' Caused by: java.lang.Exception: No native library is found…
Roman
  • 2,464
  • 2
  • 17
  • 21
138
votes
14 answers

Android Room Persistence Library: Upsert

Android's Room persistence library graciously includes the @Insert and @Update annotations that work for objects or collections. I however have a use case (push notifications containing a model) that would require an UPSERT as the data may or may…
Tunji_D
  • 3,677
  • 3
  • 27
  • 35
129
votes
20 answers

View contents of database created with Room Persistence Library

Is there any easier way to see the contents of database created with Room Persistence Library in Android Studio?
SpiralDev
  • 7,011
  • 5
  • 28
  • 42
1
2 3
99 100