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
19
votes
5 answers

Attempt to reopen an already-closed object sqlitedatabase

I have a databaseHandler. I need to count the rows in table. App crashes by this error: android attempt to reopen an already-closed object sqlitedatabase. I simply use this code in activity: db.getContactsCount(); But app crashes. Furthemore I want…
Namikaze Minato
  • 1,332
  • 4
  • 23
  • 41
19
votes
11 answers

How to check database on not rooted android device

I am developing an app where i am using sqllite3 database to store values. I have Nexus S and Nexus 7 both are unrooted devices. How can i get the database for my app for debugging purpose. I have tried (1) I have tried all approach mentioned…
CodingRat
  • 1,934
  • 3
  • 23
  • 43
18
votes
3 answers

Sugar ORM just won't create tables

I am working on a standalone library project that requires persisting a simple model. Here is what my SugarRecord looks like: /** * Keeping track of previously received messages by ID */ public class MessageRequestIdModel extends SugarRecord { …
Angad
  • 2,803
  • 3
  • 32
  • 45
18
votes
4 answers

Difference between CursorLoader and AsyncTaskLoader

Why should I use AsyncTaskLoader, and when should I prefer CursorLoader and vice-versa ? In official page, the App-listing example is shown, this uses AsyncTaskLoader instead of CursorLoader. What are the advantages and disadvantages of these two? I…
Nabin
  • 11,216
  • 8
  • 63
  • 98
18
votes
4 answers

Android: Bulk Insert, when InsertHelper is deprecated

There is plenty answers and tutorials using InsertHelper to do fast bulk insert in SQLiteDatabase. But InsertHelper is deprecated as of API 17. What is now the fastest method to bulk insert large sets of data in Android SQLite ? So far my greatest…
Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
17
votes
11 answers

SQLite returned an error code of 14

I am trying to copy an existing database from my assets folder and execute some operations on it. Everything is working fine but I've gotten the following error in the log files of my emulator: sqlite returned: error code = 14, msg = cannot open…
Kishore
  • 2,051
  • 5
  • 26
  • 45
17
votes
1 answer

Android Q: SQLite database in scoped storage

In Android Q introduced new Scoped storage feature, which says: apps that target Android 10 (API level 29) and higher are given scoped access into external storage, or scoped storage, by default. Such apps have access only to the app-specific…
Barmaley
  • 16,638
  • 18
  • 73
  • 146
17
votes
1 answer

Get row ID of an SQLite FTS3 table

I have created an SQLite FTS3 table that I am using within the Android development platform (target is 2.2 and minVersion is 8). For example, I created the table as follows: create virtual table person using fts3(first,last); I know that when I…
jake
  • 1,405
  • 3
  • 19
  • 33
17
votes
2 answers

One-to-many relation in Room

I've been using SugarDB for most of my projects in the past. It was easy to use and satisfied most of my requirements but since that project has been abandoned, decided to look at alternatives and Room seems like the best option. However, some…
Asim
  • 6,962
  • 8
  • 38
  • 61
17
votes
1 answer

Accessing a certain downloaded .sqlite database in external storage from an android app

I am trying to implement an offline map feature in an android WebView-based app: Using DownloadManager, I download an sqlite database file (of a structure like .mbtiles) from our webserver, which contains blobs of the map tile images (the "offline…
M.S.
  • 312
  • 1
  • 12
17
votes
3 answers

Warning : Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead

I developed an application in which I copied the database from the assets folder to my path which is hardcoded. So eclipse gives me warning : Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead I searched in google and found the…
Manoj Fegde
  • 4,786
  • 15
  • 50
  • 95
17
votes
1 answer

Phonegap/SQLite no such table errors for CacheGroups, Caches, Origins, and DeletedCacheResources

I have a PhoneGap application using SQLite. My database and tables generated from code are being initialized and created properly and the application is running queries fine against these tables. Strangely, I'm seeing the following errors in…
activelogic
  • 1,325
  • 3
  • 14
  • 24
16
votes
4 answers

SQLiteReadOnlyDatabaseException: attempt to write a readonly database (code 1032)

So in some rare instances, I'm seeing the "attempt to write a readonly database" message, and I can't figure out where the problem lies. I'll start with the stacktrace in my logcat... as you can see from the timestamp I'm checking db.isReadOnly()…
AWT
  • 3,657
  • 5
  • 32
  • 60
16
votes
4 answers

SQLite database update query with multiple where conditions in Android

I want to update my database table with multiple where conditions. I already did with single where condition db.update(TABLE_MISSING_ITEMS, values, KEY_AUTHOR + " = ?", new String[] { String.valueOf(items.getAuthor()) }); Now i…
Rohit
  • 810
  • 2
  • 9
  • 34
16
votes
2 answers

When does OnUpgrade get called and how does it get the oldVersion parameter?

I am working on an update for my current app. My app use SQLite DB and so far I am at version 1. I will need to alter/introduce new tables in my second version. I did my research and I found that to do that the best way is to have switch(case)…
Snake
  • 14,228
  • 27
  • 117
  • 250