android-sqlite

Unable to prevent SQLiteConnection object leakage

旧街凉风 提交于 2020-07-13 02:22:23
问题 In my android app I have some Database transaction using SQLite but I am getting SQLiteConnection object leakage despite trying many ways to prevent the leak. I have almost tried each and every thing in the internet like closing the db, closing the cursor, or ending the transaction. Below is the warning in android studio. A SQLiteConnection object for database '/data/user/0/com.example.myapp/databases/myapp.dbnotes.db' was leaked! Please fix your application to end transactions in progress

Using Room, how to get the last inserted auto-generated ID , including when the table didn't get anything inserted into it?

余生长醉 提交于 2020-06-29 07:03:36
问题 Just a solution that someone wrote to me that I think could be useful: Background I just wanted to know if the table was ever been modified, so I thought that maybe by getting the last generated ID this could be a way to do it, and since I know this value should be saved somewhere, it should be possible to get it. My idea : Using Room, get the last inserted auto-generated ID (even if nothing was ever inserted) , without modifying the table or create any additional table. The problem I couldn

Using Room, how to get the last inserted auto-generated ID , including when the table didn't get anything inserted into it?

北战南征 提交于 2020-06-29 07:03:10
问题 Just a solution that someone wrote to me that I think could be useful: Background I just wanted to know if the table was ever been modified, so I thought that maybe by getting the last generated ID this could be a way to do it, and since I know this value should be saved somewhere, it should be possible to get it. My idea : Using Room, get the last inserted auto-generated ID (even if nothing was ever inserted) , without modifying the table or create any additional table. The problem I couldn

Room best ways to create backups for offline application?

≯℡__Kan透↙ 提交于 2020-06-26 06:54:17
问题 So I have let's say pretty complex database which is using many to many database design with foreign keys and join tables and it's Room database. I want to create backup system for it because it's offline application I would need to export database and store it to google drive's app folder. I have read quite a lot about it in recent day's but still a bit confused I saw that there is ways to export database as CSV , JSON , excel files or just as .db file, but what are the best practices for

Room best ways to create backups for offline application?

半腔热情 提交于 2020-06-26 06:54:04
问题 So I have let's say pretty complex database which is using many to many database design with foreign keys and join tables and it's Room database. I want to create backup system for it because it's offline application I would need to export database and store it to google drive's app folder. I have read quite a lot about it in recent day's but still a bit confused I saw that there is ways to export database as CSV , JSON , excel files or just as .db file, but what are the best practices for

Create Room Entity for a Table which has a field with LONG datatype in Sqlite

点点圈 提交于 2020-06-24 14:15:53
问题 App Database has Items table with a column Price with datatype Long . Db Version = 1 CREATE TABLE items (_id INTEGER PRIMARY KEY AUTOINCREMENT,item_id INTEGER,title TEXT,price LONG, UNIQUE (item_id) ON CONFLICT IGNORE) While trying to migrate to Room I am experiencing below issue java.lang.IllegalStateException: Migration didn't properly handle items(moka.pos.test.data.entity.Item). Expected : price=Column{name='price', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0} Found

Android Room Database, retrieve specific value of the latest record entered

白昼怎懂夜的黑 提交于 2020-06-17 14:53:47
问题 I have used Android Room Database to create my app, I am filling records of students, I want to retrieve page number of the latest record that I have entered from the Room Database when I select student's name. This is my code below DOA @Dao public interface NewRecordDAO { @Insert(onConflict = REPLACE) public void addRecord(NewRecord... newRecord); @Update(onConflict = REPLACE) public void updateRecord(NewRecord newRecord); @Delete public void deleteRecord(NewRecord newRecord); @Query("DELETE

How to set a max items for a specific table using Trigger, in SQLite?

ε祈祈猫儿з 提交于 2020-06-16 17:25:39
问题 This is a simple question. Background I'm supposed to have max of 400 rows in some table, based on timestamp field, so old ones will be removed automatically. For here, let's say it's 3 instead. The table has various fields, but the timestamp is what's important here. The problem Even though I've succeeded (looked here), for some reason it got me to a max of an additional item, so I just adjusted it accordingly. This means that instead of 3, I got 4 items. private const val MAX_ITEMS = 3

Android Room - Usage of foreign key in query

瘦欲@ 提交于 2020-06-12 19:56:25
问题 I have a Component which contains a foreign key coming from Component_category My purpose is that a component list will be filtered by the selected component category. Both classes are as followed: Component @Entity(tableName = "component_table", foreignKeys = { @ForeignKey( entity = Rack.class, parentColumns = "rack_id", childColumns = "component_id", onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE ), @ForeignKey( entity = ComponentCat.class, parentColumns = "component_cat_id",

Android Room - Usage of foreign key in query

天涯浪子 提交于 2020-06-12 19:46:09
问题 I have a Component which contains a foreign key coming from Component_category My purpose is that a component list will be filtered by the selected component category. Both classes are as followed: Component @Entity(tableName = "component_table", foreignKeys = { @ForeignKey( entity = Rack.class, parentColumns = "rack_id", childColumns = "component_id", onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE ), @ForeignKey( entity = ComponentCat.class, parentColumns = "component_cat_id",