Questions tagged [sqliteopenhelper]

SQLiteOpenHelper is a class from the Android SDK which can be used for easier handling of a SQLiteDatabase.

Using the SQLiteOpenHelper only requires implementing its two abstract methods(other methods for different events can be implemented if the user chooses) onCreate(used for initializing the database) and onUpgrade(used when the database is being changed). The Android system will call this methods according to the state of the database( not created/created/upgrading) and in return, it will offer the user a valid SQLiteDatabase reference with the methods getWritableDatabase() and/or getReadableDatabase(). More information can be found in the documentation for the SQLiteOpenHelper class.

801 questions
6
votes
1 answer

can I create variable in trigger of sqlite?

I want to create a update trigger, can I create a variable betweent "BEGIN" and "END" , and set value by query from a select sql statement ?? And then execute "if" "else" statement by judging this variable
waiter.james
  • 591
  • 2
  • 6
  • 16
6
votes
1 answer

Confused about CursorLoaders and using them with a custom SQLiteOpenHelper

I'm writing an app that allows people to set alarms for various tasks that they need to do. My current plan is to store all the relevant data into an SQLite database. To that end, I have created a class that extends SQLiteOpenHelper and filled it…
6
votes
1 answer

What is the fastest way to parse a JSON string into an SQLite table?

I'm writing an Android application which will occasionally need to download a json string of around 1MB and containing around 1000 elements, and parse each of these into an SQLite database, which I use to populate a ListActivity. Even though the…
simick
  • 63
  • 1
  • 3
5
votes
3 answers

Is it really necessary to create SQLite tables every time the application starts?

I've noticed in more than one SQLite tutorial that the table is recreated in the onCreate() event of the class that extends SQLiteOpenHelper. I've already created my SQLite database and tables outside the Android environment (Eclipse IDE) with the…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
5
votes
2 answers

SQLiteOpenHelper - creating database on SD card

in my test android app I intend to create and access database file, which will be located on SD card. I am using main activity with help of a class, which extends SQLiteOpenHelper. I want to use it the same way as before, but I have to somehow…
Waypoint
  • 17,283
  • 39
  • 116
  • 170
5
votes
1 answer

Exported SQLite database is not up to date

This issue only applies to an SDK 28 device (emulator). My SQLite database created with SQLiteOpenHelper works perfectly in the app, however when I export it to a disk (either by means of Android studio or by the code), much of its data is lost.…
5
votes
2 answers

How to create table using sqlite fts5 in android?

I want to create a table using fts5 extension CREATE VIRTUAL TABLE TABLE_FTS_FOOD_ITEM USING fts5 (content='food_items', Shrt_Desc, Energy_Kcal); but I am getting this error. android.database.sqlite.SQLiteException: no such module: fts5 Earlier…
Sonam Pasi
  • 562
  • 1
  • 4
  • 19
5
votes
1 answer

SQLiteOpenHelper Application has opened too many files

I am facing a problem with my android app. I am running into this issue: SQLiteOpenHelper: Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default. (unknown error (code 2062): Could…
Tong Jun Qun
  • 51
  • 1
  • 3
5
votes
2 answers

Deciding between Activity Context or Application Context to Instantiate SQLiteOpenHelper

I am new to Android development (to development overall to be frank), and as such I have been reading Commonsware Busy Coder's guide. While reading through the SQLite section, there are a couple things that are not %100 clear to me. Below is what I…
Emmanuel
  • 13,083
  • 4
  • 39
  • 53
4
votes
1 answer

Android does not update SQLite database

I am experiencing some trouble with an SQLIte database in my Android application. The issue is that the database is never updated, not even on multiple restarts of the emulator, of Eclipse or after deletion from DDMS. This is my onCreate method,…
Tilvia
  • 43
  • 1
  • 5
4
votes
0 answers

Access sqlite database of flutter sqflite plugin from native

I am developing an flutter app, and it have several native parts, in flutter jam using sqflite plugin to create the database file. initDB() async{ String databasPath = await getDatabasesPath(); String path = join(databasPath,'eshaar.db'); var Db =…
4
votes
0 answers

SQLiteOpenHelper instance in multiple Activities and Fragments

tl;dr: What's the best way of handling instance of SQLiteOpenHelper class in an app with multiple Activities and Fragments? Should I have only one instance in the whole app and pass it between individual Activities, or can I create a new instance…
4
votes
2 answers

Updating Database in Background task (Android)

My app makes use of SQLiteDatabase to save two arraylists to separate tables. I have noticed that since implementing the database, whenever it updates the database (involving dropping the tables, recreating them, then populating them with the…
Isengrim
  • 59
  • 1
  • 11
4
votes
2 answers

Android SqliteAssetHelper - merging database tables from asset with the existing one

I am using Android SqliteAssetHelper library (https://github.com/jgilfelt/android-sqlite-asset-helper) I have shipped my database using this library and the database contains some records on table1. Now I want to update my app with a new database…
user1930106
  • 779
  • 1
  • 6
  • 19
4
votes
0 answers

Method getReadableDatabase in android.database.sqlite.SQLiteOpenHelper not mocked

I'd like to test the methods inside the databasehelper class. I develop with Android studio. I use Mockito for testing and I got error message running the test: Method getReadableDatabase in android.database.sqlite.SQLiteOpenHelper not…
Ferenc
  • 41
  • 4