sqlite

Duplicate column name on SQLite upgrade for a new column

蓝咒 提交于 2020-07-20 10:13:31
问题 I've been getting an inconsistent, non-reproducible crash upon users upgrading to a new version of the local SQLite DB when updating the app. Fatal Exception: android.database.sqlite.SQLiteException: duplicate column name: upload_pending (code 1): , while compiling: ALTER TABLE purchases ADD COLUMN upload_pending TINYINT DEFAULT 0 ################################################################# Error Code : 1 (SQLITE_ERROR) Caused By : SQL(query) error or missing database. (duplicate column

Android Paging library sqlite data storage concern

◇◆丶佛笑我妖孽 提交于 2020-07-19 11:13:17
问题 Over the past days I have been getting comfortable with Android Architecture Components and I've been mostly interested in the Paging Library for handling and displaying lists of data from a remote source. For the best UX it is better to load data first into the database, in this case Room then display it in a recyclerview using the pagingLibrary and adapters. My concern is this, lets say an api has 1000s of records or a twitter feed even and all this data has to pass through the db then to

Android Paging library sqlite data storage concern

送分小仙女□ 提交于 2020-07-19 11:12:58
问题 Over the past days I have been getting comfortable with Android Architecture Components and I've been mostly interested in the Paging Library for handling and displaying lists of data from a remote source. For the best UX it is better to load data first into the database, in this case Room then display it in a recyclerview using the pagingLibrary and adapters. My concern is this, lets say an api has 1000s of records or a twitter feed even and all this data has to pass through the db then to

Attempt to invoke virtual method 'android.database.Cursor android.database.sqlite.SQLiteDatabase.query on null object reference [duplicate]

烈酒焚心 提交于 2020-07-19 05:34:08
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 4 years ago . I have an activity in which i am trying to get the list of data based on some condition . This selectsome() function is in the SQLiteOpenHelper subclass. MyDBHandler dbhelper = new MyDBHandler(this); Cursor cursor; cursor = dbhelper.selectSome(value); In class MyDBHelper.java public Cursor selectSome(String arg) { String columns[]=new String[]{"_id","_hotelname","

is there any way to run nested query in room database

让人想犯罪 __ 提交于 2020-07-18 07:45:14
问题 I am migrating my old Android project to new standards, I got stuck in between room database , not able to find how to execute these 2 SQLite commands using room database . I have 2 queries which are working in a nested manner, so to achieve the same result using room is there any possibility. default public ArrayList getOfflineRoomsAndObjectsByParentIds(String parentId, String site_id, Context context) { databaseHandler = new DatabaseHandler(context); Cursor cr = null; ArrayList<Room>

Best Practice for loading data from server (Android App)

爷,独闯天下 提交于 2020-07-18 07:31:24
问题 I'm building an Android app, which should: show some data, loaded from a server in the Internet. At the moment I have a local SQliteDB used in my app where the data is stored, which should be displayed. I use this, because I want to be able to show the data, even if there is temporarily no internet connection available. Next step I will work on inserting data in the local SQliteDB from a internet server. I thought about doing it this way: When app starts, check if internet is available. If

Programmatically set browser cookie (Firefox)

我的未来我决定 提交于 2020-07-18 05:37:10
问题 I know from this question that Firefox 3.0 and up stores its cookies in an SQLite database. My question is: can you access this database from other desktop programs in such a way that you could add a cookie? I realize this has security implications. However, I do not want to read them at all. I want to be able to set one cookie if possible. I don't even want to overwrite a cookie. I just want to add it if it isn't there already. This is sort of a personal project I'm working on for fun. This

sqlite3 remove brackets from printed data

帅比萌擦擦* 提交于 2020-07-18 03:07:18
问题 I have created a script that finds the last value in the first row of my database import sqlite3 global SerialNum conn = sqlite3.connect("MyFirstDB.db") conn.text_factory = str c = conn.cursor() SerialNum = c.execute('select Serial from BI4000 where Serial in (Select max(Serial) from BI4000)') print SerialNum conn.commtt() conn.close() the program prints the result [('00003',)] which is the last result in the current database, all the data that will be entered into the final database will be

sqlite3 remove brackets from printed data

做~自己de王妃 提交于 2020-07-18 03:05:09
问题 I have created a script that finds the last value in the first row of my database import sqlite3 global SerialNum conn = sqlite3.connect("MyFirstDB.db") conn.text_factory = str c = conn.cursor() SerialNum = c.execute('select Serial from BI4000 where Serial in (Select max(Serial) from BI4000)') print SerialNum conn.commtt() conn.close() the program prints the result [('00003',)] which is the last result in the current database, all the data that will be entered into the final database will be

Sqlite get max id not working (?)

流过昼夜 提交于 2020-07-17 11:27:05
问题 Im using this: SELECT * WHERE id=MAX(id) FROM history; But my query is empty. I have also tried this (This one works): SELECT MAX(id) AS max_id FROM history; But obviusly my query only contains the max_id key. What am I doing wrong with the first one? 回答1: You need to add another level of select for the MAX , like this: SELECT * WHERE id=(SELECT MAX(id) from history) FROM history; A better approach would be to order by id in descending order, and limit the output to a single row: SELECT *