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
1
vote
1 answer

SQLiteException: no such table: database-notes (code 1 SQLITE_ERROR)

I'm trying to migrate a new database version. The only thing changed is an added column. I always get the following error: android.database.sqlite.SQLiteException: no such table: database-notes (code 1 SQLITE_ERROR): , while compiling: ALTER TABLE…
BlazeCodeDev
  • 631
  • 1
  • 7
  • 27
1
vote
1 answer

How to migrate Room db from 1 to 2?

I'm trying to migrate my Room db to the next version and I keep getting the same error: java.lang.IllegalStateException: A migration from 1 to 2 was required but not found. Please provide the necessary Migration path via…
BlazeCodeDev
  • 631
  • 1
  • 7
  • 27
1
vote
1 answer

Android Sqlite not updating prepopulated database

I am using prepopulated sqlite database in my android application. Now the problem is when i update data in my database and i increment the databse version onUpgrade() method is called but my database is not updated. Any help would be…
1
vote
1 answer

Android Room Embedded Field Not Compiling

I am trying to create an embedded field. This is a simple example but I can't get this simple example to work. Eventually I need to have 3 levels of embedded items but trying to get this test case to work. @Entity(tableName =…
JPM
  • 9,077
  • 13
  • 78
  • 137
1
vote
2 answers

Is there a way to use SQLiteDatabase with Room?

I need to be able to perform a some operations that would be easily done with SQLiteDatabase but I'm using Room. Is there a way for me to get an instance of a SQLiteDatabase object for that Room database? I've already tried the RoomDatabase object…
casolorz
  • 8,486
  • 19
  • 93
  • 200
1
vote
2 answers

Trying to prepopulate Room Database from a json using Hilt

I have an app where I am prepopulating my Room Databse with a json file. Here is my database setup for that: @Database(version = 2, entities = [(ClimbingRoute::class)], exportSchema = false) abstract class ClimbingRoutesDatabase : RoomDatabase() { …
1
vote
1 answer

how to add prefix in roomDatabase?

I have a problem in my roomDatabase. I searched on google and found some solutions but I can't solve my problem. Can anyone help me? Note : I want to use Object Oriented in my project. Error : Multiple fields have the same columnName: class_id.…
1
vote
1 answer

Fetching data from sql databse in flutter datewise?

I am making an app in flutter and I am implementing SQL database using the sqflite plugin. In this app, users can create transactions by filling out the form below Then the user can verify their transactions and they also will be having an option…
1
vote
1 answer

Different typeconverters for different custom object entity in room database

Here i need to store multiple custom entities in same table in room database. This things are working in single typeconverter but when it comes in the case of multiple typeconverters then it is throwing error. import androidx.room.Entity import…
Lazy Mind
  • 143
  • 9
1
vote
1 answer

How can I ORDER BY a query in Rooms database using date and time which is stored in String format?

I have date and time stored in "yyyy-mm-dd HH:mm" format in my Rooms Database as a String. I want to get the data in descending order of date and time from my Rooms database, however since it is in String format, how can I achieve that?
1
vote
0 answers

How to get table(entity) size in room?

It's easy to get the database size but it also includes tables which I don't require when I'm doing it for my analytical study. What I want to know is if there is any easy way to get the table size specifying by it's name in room…
Ashutosh Soni
  • 855
  • 3
  • 9
  • 22
1
vote
0 answers

How to retrieve a list of rows for a given username and userID from Rooms database?

I have a Rooms database which stores flight information, and I want to retrieve a list of flights which are associated with a given username and userID. I am attaching herewith the code for my activity Activity code …
1
vote
1 answer

How do I update specific columns in Rooms database table on Android using target entity?

I want to update only specific columns in my table in my Rooms database, and am using the target entity class by Android Rooms. However, when I execute the function, the value in the table does not get updated. Below are the activity class code, dao…
1
vote
0 answers

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

I want to check if I have a given parameter value in my Room database using Java. If it is there then I just update the record, otherwise I insert a new one. How can I get this done? FlightDAO @Query("SELECT EXISTS (SELECT * FROM flight_table WHERE…
Ian Bell
  • 533
  • 5
  • 18
1
vote
3 answers

Call Application context in Activity

I'm trying to call my database (made with Room) from an activity on Android, but it needs the application context, and if I passed "application : Application" in the constructor of my Activity, the build crash and tell me…
Ferenc
  • 39
  • 7