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
4
votes
3 answers

Android database helper singleton - instantiate in activity or all fragments?

I have a DBHelper class set up as a singleton: public class DBHelper extends SQLiteOpenHelper { private static DBHelper sInstance; public static synchronized DBHelper getInstance(Context context) { if (sInstance == null) { …
4
votes
2 answers

Does OnResume() in Android makes Activity loading faster?

I was developing an Android Application where I have to load a large data from Android Database and view it on screen. In earlier stages of development I used to retrieve data from DB in OnCreate() method and it really slowed the start of activity…
Lalit Umbarkar
  • 443
  • 7
  • 15
4
votes
1 answer

Android: CSV database vs SQLite database

How does a CSV database compare to an SQLite database in Android? Looking at other questions on StackOverflow, and reading Android Developer Documentation, I have seen SQLite databases being used far more often than reading data from a CSV file.…
Farbod Salamat-Zadeh
  • 19,687
  • 20
  • 75
  • 125
3
votes
1 answer

Google play game services with Room database

We have a simple trivia game which is currently using Room database to store all the data including users progress. We now want to integrate Google play game services to store the progress on cloud so user can have their progress when the device is…
3
votes
1 answer

Android Room Database Ignore Problem "Tried the following constructors but they failed to match"

My entity class: @Entity(tableName = "student") data class Student( var name: String, var age: Int, var gpa: Double, var isSingle: Boolean, @PrimaryKey(autoGenerate = true) var id: Long = 0, @Ignore …
Sam Chen
  • 7,597
  • 2
  • 40
  • 73
3
votes
1 answer

Room Migration- How to add a new NON-NULL and String type column to existing table

I am developing an android application and in my app i have implemented Room Database. My app is already live on playstore as now i am trying to send an update to app where there are changes in schema. I have added new column, its type is string and…
NS.
  • 98
  • 1
  • 13
3
votes
1 answer

How to view couchbase lite database on windows?

I am new to couchbase lite implementation, i am working on Android platform and i have created a database,saved a simple document in it. Now i want to extract the database and view the document saved in it. I placed a sample json in raw folder, read…
User
  • 692
  • 2
  • 11
  • 29
3
votes
2 answers

How to get date from room database

I use room database and want to save date in database. I want to save date with this format "dd/MM/yy" to database. So i create DateConverter class to written from/into the database. Now i can save date with my favorite format into the database but…
3
votes
2 answers

Room database error : Migration didn't properly handle

I want to use Room library for my database application. I want open a database from assets folder and get all rows. I used this way for open database : https://github.com/humazed/RoomAsset . Error : java.lang.IllegalStateException: Migration…
3
votes
2 answers

Live data returning old values , onChanged is triggering multiple times

I am using live data to update some view of the activity. the view contain question numbers both total question number and answered question number eg: 2/10 (answered/total) the questions can be filtered using actors, if no actor is selected then…
MarGin
  • 2,078
  • 1
  • 17
  • 28
3
votes
1 answer

android room migrate not call

In my application, I needed a migration to create a new table and insert data into it. the table itself was created but there is no data there, and I tried to debage the migration call method, but it was not called. Why is migration not…
Nikitc
  • 795
  • 1
  • 6
  • 12
3
votes
1 answer

Android Room one-to-one relation (getting foreign fields)

I want to implement android ROOM to my project. But I can not solve one-to-one relation between Order(customer_id) and Customer(id). Is it possible to fill customer (@Ignore protected Customer customer) field in OrderDao interface? I can solve only…
chrome
  • 661
  • 2
  • 7
  • 23
3
votes
1 answer

How do I update columns of a Room entity only if it's null?

Is there a way to update columns of an entity only if the columns are null? Here's my Update function in my DAO interface: @Query("UPDATE media SET media_name = :mediaName, media_data = :mediaData WHERE id = :id") fun update(id: Int, mediaName:…
3
votes
2 answers

Android Studio Error in SQLiteDatabase - Drop if table exists

The following code @Override public void onUpgrade(SQLiteDatabase db, int i, int i1) { db.execSQL("DROP IF TABLE EXISTS " + TABLE_NAME); onCreate(db); } always gives an error index table trigger or view got if Why is that? I…
Yannick
  • 33
  • 1
  • 5
3
votes
1 answer

What is the difference between inserting data using ContentValues and Raw SQL in SQLite Android?

I want to know the difference between inserting data using ContentValues and inserting data using Raw SQL in SQLlite(Android), Is there a advantage using content values?