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
9
votes
1 answer

function to check if SQLite is using journal_mode=WAL or journal_mode=DELETE

I was looking for function which would help me to see which journaling mode is enabled.. I looked here too list of function There was function to check database status sqlite3_db_status(....) but status parameter didn't have option for check…
Sumit Murari
  • 1,597
  • 3
  • 28
  • 43
9
votes
3 answers

Data Types used in SQLite

I'm confused what to declare as datatype in SQLite for the following: 1.email 2.phone number 3.password(Some articles I find that they use String instead of int for phone number and password , why is it so?)
user3127791
  • 91
  • 1
  • 3
  • 5
9
votes
1 answer

Is it necessary to use a connection pool when using SQLite in Serialized mode?

I am a newbie for SQLite and I have read that the Serialized mode of SQLite is thread-safe, and can be safely used by multiple threads with no restriction. My question is: In a single-threaded app, is there any performance impact if I use one same…
SimonFisher
  • 380
  • 1
  • 4
  • 13
9
votes
1 answer

Simulate ORDER BY in SQLite UPDATE to handle uniqueness constraint

I have a table in SQLite 3 thus: sqlite> .schema CREATE TABLE table1 (id INTEGER PRIMARY KEY NOT NULL, title TEXT UNIQUE NOT NULL, priority INTEGER UNIQUE NOT NULL); Here is some sample data, for…
user82216
9
votes
2 answers

How do I combine data from two separate tables into a single Cursor?

Currently, I have a table of posts and a table of users. Naturally, each user can be associated with multiple posts. Each row in the post table stores the user ID of the user that created the post. Here are example rows: Post row: post_id headline…
cheese1756
  • 1,719
  • 3
  • 17
  • 25
9
votes
2 answers

How to select data between two dates from sqlite db in dd-mm-yyyy format?

i have date column in my database in dd-mm-yyyy format. i want to search the data between two dates. i tried SELECT * FROM t_data where orderdate between '01-05-2012 00:00:00' and '31-05-2012 23:59:59' and SELECT * FROM t_data where orderdate >=…
kannan
  • 317
  • 1
  • 4
  • 12
9
votes
1 answer

Android: How to requery a Cursor to refresh ListView after deleting database row?

This might be a noob question but I'm quite new to all this SQLite-Database-Cursor-Adapter-ListView-Do-It-Properly-Stuff. What I have: In my MainActivity I have a ListView. I use an SQLite database and populate the ListView with a custom adapter…
9
votes
2 answers

Android error: Cannot perform this operation because the connection pool has been closed

I have searched StackOverflow and the web for an answer to this question, but I could not find an answer. When I run my application on Gingerbread, it runs fine. But when I run it on 4.2.2, I get this error: java.lang.IllegalStateException Cannot…
Buneme Kyakilika
  • 1,202
  • 3
  • 13
  • 34
9
votes
1 answer

Singleton vs a static inner class for Database Helper class in Android

I am trying to see which of these implementation is better for accessing sqlite database in Android Applications Implementation 1 Using DatabaseHelper classes extending SqliteOpenHelper and using singleton pattern. In some rare occasions I do see…
achie
  • 4,716
  • 7
  • 45
  • 59
9
votes
3 answers

How to replace existing sqlite database file with new database file in android

Im doing an app which uses sqlite database There is an feature in my app having a button 'Update Database'. When user clicks on the 'Update Database' button i need to upgrade the old db file with new db file from URL. How to do this. the research…
Ankit Dhadse
  • 1,566
  • 1
  • 15
  • 19
9
votes
3 answers

What would happen if I don't close the database in Android?

This title may sound a little bit crazy, but this is what is making me confused. My app heavily uses local database operations. As suggested in the Android docs and some blogs, I extended the SQLiteOpenHelper class and defined all my DB operations…
Ganesh K
  • 2,623
  • 9
  • 51
  • 78
8
votes
1 answer

When testing Room AutoMigrations, what do I pass to runMigrationsAndValidate?

When using Room AutoMigrations, the Migration itself is automatically generated. But in order to unit test the migration, I have to pass a Migration object to runMigrationsAndValidate. What should I pass here? @RunWith(AndroidJUnit4::class) class…
Florian Walther
  • 6,237
  • 5
  • 46
  • 104
8
votes
0 answers

@Relation Room DB with multiple columns

If i want to related 2 tables and the relation is not only one column but more, is there a way to use the Room @Relation annotation with more arguments to achive that? Perhaps somehting like below @Relation(parentColumn = "{message_id,account_id}",…
james04
  • 1,580
  • 2
  • 20
  • 46
8
votes
3 answers

Android: column '_id' does not exist

I am getting this error IllegalArgumentException: column '_id' does not exist When using a SimpleCursorAdapter to retrieve from my database, and the table does indeed have this _id column. Noticing this a common problem, I have tried to work…
MindDrip
  • 201
  • 1
  • 4
  • 14
8
votes
2 answers

Room - Why use @Relation over @ForeignKey?

My current goal is to have a one-to-many relation in my data. From various tutorials I've come to understand that I have two main ways of doing this. Create two entities and have the child use the @ForeignKey annotation Create these two entities…
Big_Chair
  • 2,781
  • 3
  • 31
  • 58