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
2
votes
2 answers

Android - Realm how to query by boolean

I have started to use ´Realm´ and I cannot figure out how to get all the results with the value equals to true. Take a look my code below: Java Class @RealmClass public class Bookmark extends RealmObject { private java.lang.String IdBookMark; …
gon250
  • 3,405
  • 6
  • 44
  • 75
2
votes
1 answer

Cursor issue with ActiveAndroid

I'm using ActiveAndroid and everything was working fine until I addded another ForeignKey to one model. I have a model called Song which is like: @Column(name = "author_id") private String mAuthorId; @Column(name = "created") private long…
FVod
  • 2,245
  • 5
  • 25
  • 52
2
votes
1 answer

Why ORMLite & Green DAO are faster then traditional SQLite?

I would like to know why ORMLite & GreenDAO are faster then traditional SQLite ? As per my knowledge internally all are doing same quires for interacting with database like SQLite then why others are faster? Thanks in advance !!
Adarsh Yadav
  • 3,752
  • 3
  • 24
  • 46
2
votes
2 answers

Android: how to make a migration script for a specific version

My app's currently released versionCode is 15, & I want to run some migration code to fix users' data on the app's database (not the schema structure). So, how to run the fixing code only once for people upgrading from any version less than or equal…
AbdelHady
  • 9,334
  • 8
  • 56
  • 83
2
votes
1 answer

Android CursorLoader with selection and selectionArgs[]

I am using Loader for RecyclerView.Adapter to list items. I want to list specific items from database table. So i did: public Loader onCreateLoader(int id, Bundle args) { String selectionArgs1[]={"1","13","14"}; String selection1 =…
1
vote
1 answer

Data isn't completely removed from my android app

I found a very strange bug in my application. The fact is that after deleting the application, logging out of the account and deleting all data, as well as after clearing the data through the system dialog, when I enter the application I get to…
1
vote
1 answer

Android Room additional constructor parameter

I have an entity looking as follows: @Entity(tableName = "my_table") public class MyEntity { @PrimaryKey(autoGenerate = true) @ColumnInfo private final Integer id; @ColumnInfo private final String data; @Ignore private…
1
vote
2 answers

Why can't I use suspend modifier in dao's @Insert in room database?

When I use the @Insert function in DAO, the following error occurs. error: Type of the parameter must be a class annotated with @Entity or a collection/array of it. All other codes using Room use suspend in @Insert, so I don't know the cause of the…
ybybyb
  • 1,385
  • 1
  • 12
  • 33
1
vote
2 answers

How to delete a Row from the DB in android

I'm new to android ... i have developed a Database application , were i'm able to insert the textfield details , but i want to delete the specific row , i need to search by name and delete the user. can someone help me on this : My DB code…
1
vote
0 answers

How to get the latest updated item from LiveData?

Everytime i add new item to database using Livedata, it is retriving all data from database. But i want only the latest updated item to display on the screen when i click save button Here is the Code MAIN ACTIVITY …
1
vote
1 answer

Update android room parent database together with children

In my android application, I have a parent and child database in a one-many relation, using a foreignkey to bind a column of the child database with an element of the parent. The parent has columns period [acts as…
dlw
  • 103
  • 1
  • 8
1
vote
1 answer

Why do time-consuming operations in `lifecycleScope.launch` block the UI thread?

I read list of pages from database and display on RecyclerView. It looks like this: ViewModel: @HiltViewModel class BookDetailViewModel @Inject internal constructor( savedStateHandle: SavedStateHandle, private val bookRepository:…
1
vote
0 answers

Why should I use a ContentProvider with exported=false?

I can't figure out why I should use a ContentProvider with the setting "android:exported=false" in the AndroidManifest.xml. Aren't ContentProviders created to share data between multiple applications? In this way, I am restricting data sharing only…
1
vote
0 answers

How do I insert initial data in a SQLite database table?

I'm currently trying to create an Flashcard application, in which the user can either create his own cards/notes or use pre-defined cards. The idea is to have around 500 to 1000 cards to be inserted on the database right after its creation. But how…
1
vote
0 answers

migrate Android sqlite database to another app

I have an app with a sqlite database and user data. I have made a new app but it uses the same structure and I would like to migrate the data from the first app. Both apps need to be in the app store, therebefore I cannot just update the app. Is…
Nico
  • 1,071
  • 1
  • 23
  • 39