Questions tagged [android-sqlite]

Android uses SQLite to store and retrieve data persistently. Use this tag for questions regarding the Android implementation of SQLite, how to use it in your application, or for help when your implementation of SQLite doesn't work.

uses a SQLite database to store and retrieve data persistantly.

Every Android App gets a private SQLite database to persistantly store data.

See also

8244 questions
13
votes
1 answer

Room Database Migration Failed: ALTER TABLE to add multiple columns

I'm upgrading my Database from version 3 to version 4 by providing migration from 3 to 4. Here's my code for migration: private static Migration MIGRATION_3_4 = new Migration(3, 4) { @Override public void migrate(@NonNull…
Ravindra Barthwal
  • 380
  • 2
  • 4
  • 16
13
votes
1 answer

room error: The columns returned by the query does not have the fields fieldname

Here is a sample POJO public class Product{ private long id; private String name; private double price; ... constructor for all fields ... getters and setters } Now, in my productDAO if I have a query like this @Query(select id, name from…
Alin
  • 14,809
  • 40
  • 129
  • 218
13
votes
2 answers

What's the difference between LIKE and GLOB in SQLite?

What the difference in the following to query ? FROM COMPANY WHERE ADDRESS GLOB '*-*'; FROM COMPANY WHERE ADDRESS LIKE '%-%'; I know unlike LIKE operator, GLOB is case sensitive. Is it the only difference ?
Saeed Sharman
  • 765
  • 5
  • 24
13
votes
5 answers

SQLite unable to open database file (code 14) on frequent "SELECT" query

I have following class "Singleton" to handle SQLite connection and to make sure to have 1 instance of connection for whole process/app: public class DBController { private static DBController instance = new DBController(); private static…
JavaMachine
  • 601
  • 1
  • 9
  • 27
13
votes
2 answers

The connection pool for database '/data/data/msv_database.db' has been unable to grant a connection. Connections: 0 active, 1 idle, 0 available

I m getting following error:while accessing database from two different threads using single database object throughout the application The connection pool for database '/data/data/msv_database.db' has been unable to grant a connection to thread…
kittu
  • 265
  • 1
  • 5
  • 17
13
votes
2 answers

How to fix content provider url not found in android Content provider?

I have followed the below tutorial http://www.vogella.de/articles/AndroidSQLite/article.htm But getting this exception after clicking on "confirm" button 01-20 10:18:14.585: E/AndroidRuntime(2006): Caused by: java.lang.IllegalArgumentException:…
venu
  • 2,971
  • 6
  • 40
  • 59
13
votes
3 answers

webview crash NullPointerException android.webkit.WebViewDatabase.initDatabase(WebViewDatabase.java:234)

I recieve from google play msg that my app crash, in the msg java.lang.NullPointerException at android.webkit.WebViewDatabase.initDatabase(WebViewDatabase.java:234) at android.webkit.WebViewDatabase.init(WebViewDatabase.java:212) at…
idan
  • 1,508
  • 5
  • 29
  • 60
13
votes
5 answers

Insert in SQLite Database android

im new on Android. I have some trouble with the insert statement in the database, when im running the application the values have not been inserted. Please someone can help.. public class DatabaseAdapter extends SQLiteOpenHelper { // Database…
Richard Tunner
  • 133
  • 1
  • 1
  • 4
13
votes
4 answers

What is the purpose of an Android projection map in a content provider?

I am looking at the Android notepad application sample code in /samples/android-16/NotePad/src/com/example/android/notepad. I was wondering if anyone could explain to me why the following code is needed in NotepadProvider.java? //…
Umbungu
  • 945
  • 3
  • 10
  • 30
12
votes
2 answers

Kotlin set value of global variable

We are trying to set the value of a global variable declared in the code below class MyApplication: Application() { var globalVar = 2 } Now we have a Main Activity that has a Edit Text named etPerson we would like to enter a value in etPerson…
Vector
  • 3,066
  • 5
  • 27
  • 54
12
votes
3 answers

Check if entity from a room database is empty

How can I detect if a table has no entries using Room Persistence Library? I can't find any information on how to tackle this issue.
12
votes
1 answer

How can I get a value from LiveData?

I am using Room for the first time. I am having a look at the LiveData concept. I know that we can fetch records from DB into LiveData and haveObservers attached. @Query("SELECT * FROM users") > getAll(); But I am performing…
user2234
  • 1,282
  • 1
  • 21
  • 44
12
votes
2 answers

How to create a table with a two or more foreign keys using Android Room?

According the entity-relationship model, the relationship between tbl_post and tbl_category could be specified using Room Persistency Library as follows: @Entity(foreignKeys = @ForeignKey( entity = TblPost.class, parentColumns = "id", …
JP Ventura
  • 5,564
  • 6
  • 52
  • 69
12
votes
1 answer

Select Where date is greater than or equal to today in SQLite

I have dates stored in my Database in a dd/mm/yyyy format and I am looking to only show items where the date is equal to or great than today. I have tried WHERE date(fixtures.date) >= date('now') but I got no results. Below is my query, any help…
MMcK
  • 121
  • 1
  • 1
  • 3
12
votes
1 answer

Use ActiveAndroid on existing database-content

I developed an Android-App where I saved data in a SQLite database using the SQLiteOpenHelper. I am wondering if I could update my app by using ActiveAndroid, but in a way that the user data previously stored in the database will be preserved. Is…
deimos1988
  • 5,896
  • 7
  • 41
  • 57