Questions tagged [android-database]

General programmatic usage of databases on Android

Databases and tools related with persistence supported by the Android operating system.

584 questions
1000
votes
15 answers

Ship an application with a database

If your application requires a database and it comes with built in data, what is the best way to ship that application? Should I: Precreate the SQLite database and include it in the .apk? Include the SQL commands with the application and have it…
Heikki Toivonen
  • 30,964
  • 11
  • 42
  • 44
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
61
votes
5 answers

Database won't remove when uninstall the Android Application

I have two major questions. Database won't delete when uninstall app. Downloaded files won't delete while unstable the app. There is a database in my android application. I create it by java class as follows. public DataBaseHelper(Context…
KZoNE
  • 1,249
  • 1
  • 16
  • 27
51
votes
9 answers

Room Using Date field

I am using date converter class to convert my date object. However, I still encounter an error saying. error: Cannot figure out how to save this field into a database. You can consider adding a type converter for it. My Date Converter class public…
Sutirth
  • 1,217
  • 4
  • 15
  • 26
45
votes
5 answers

Android Room database transactions

With the new Room Database in Android, I have a requirement where there are two sequential operations that needs to be made: removeRows(ids); insertRows(ids); If I run this, I see (on examining the db) that there are some rows missing - I assume…
Rajath
  • 11,787
  • 7
  • 48
  • 62
31
votes
2 answers

Firebase Permission denied Error

I am Very beginner to firebase and trying to get value from my database. but it showing me same error every time. W/SyncTree: Listen at /child failed: FirebaseError: Permission denied My firebase rules { "Condition" : "sunny", "child" :…
27
votes
4 answers

SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1

I am getting below exception only in android 9, after reinstalling everything looks good, Exception: android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1... Code: Cursor cursor =…
Bikash Sahani
  • 312
  • 1
  • 3
  • 10
19
votes
3 answers

When to save data to database, onPause() or onStop()?

I know this question has been asked a million times, I myself though that I already knew the answer and that the correct one was that the only guaranteed call is to onPause(), so you should save your data there. However, in many places of android…
klifa
  • 671
  • 1
  • 8
  • 27
11
votes
3 answers

Android Room Database Create Entity Object without Id

My entity class: @Entity(tableName = "student") data class Student( @PrimaryKey(autoGenerate = true) val id: Long, val name: String, val age: Int, val gpa: Double, val isSingle: Boolean ) The problem is, since the id is…
Sam Chen
  • 7,597
  • 2
  • 40
  • 73
11
votes
1 answer

return sum and average using room

My table is structure is as follows: @Entity(tableName = "userFitnessDailyRecords") public class UserFitnessDailyRecords { @NonNull @PrimaryKey private Date forDay; private int stepCount; } The query I am writing for getting sum…
Sutirth
  • 1,217
  • 4
  • 15
  • 26
11
votes
2 answers

SQLiteConnection databases leak when running emulator

I was running the emulator and received the following errors about memory leak. It was interesting that the leaking database seems to be of the Google gms instead of a user database. Does anyone know how to fix it? Thanks! 09-27 15:55:07.252…
Benjamin Ting
  • 611
  • 7
  • 16
10
votes
0 answers

IllegalStateException: The file system on the device is in a bad state. WorkManager cannot access the app's internal data store

My app is not going to open. When i try to open app it immediately close with below crash. It is happening in only one device Redmi note 10s.(Android 11) It seems issue with Workmanager, but didn't found any solution The file system on the device is…
10
votes
1 answer

Can i make non-primary key field as autogenerated value in room

I have table with composite primary key. Can I make one of the filed as auto generated. Secenario : I have a teacher table containing the fields techerId, name, gender, role, department, grade and it has composite primary id which consist of role,…
Rakki s
  • 1,426
  • 1
  • 18
  • 42
9
votes
1 answer

How do I check if there's a certain item in database when using Room in Android?

@Dao interface ExampleDao { @Query("SELECT * FROM example_table WHERE id = :id") fun get(id: Int): LiveData @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(something: Example) } When I try to check if there's…
goodonion
  • 1,401
  • 13
  • 25
9
votes
8 answers

Android - How to access Room database from widget

i wanted to access Room DB inside my widget class to update the widget according to the stored data. the problem here is the ViewModelProvider require a fragment or activity to work…
1
2 3
38 39