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
16
votes
2 answers

SQLiteOpenHelper vs ContentProvider

I'm new to Android development. I'm trying to create an application that reads from the internal database (SQLite) and list all the data in a list (I'm using listView). So far I got a class called DatabaseHandler that extends SQLiteOpenHelper and…
André Alves
  • 6,535
  • 3
  • 17
  • 23
14
votes
1 answer

Correctly open/close a database with Singleton design pattern

I am creating an application which makes a lot of interactions with a database (both read and write operations). To avoid open/close operations at each request, I created a class extending SQLiteOpenHelper with a Singleton design pattern. This way,…
mithrop
  • 3,283
  • 2
  • 21
  • 40
13
votes
3 answers

Why can't I use Resources.getSystem() without a Runtime error?

public class BobDatabase extends SQLiteOpenHelper{ private static final String DATABASE_NAME = "bob.db"; private static final int DATABASE_VERSION = 1; public static final String DEFAULT_PROFILE = "default_profile"; public BobDatabase(Context…
Garzahd
  • 5,739
  • 3
  • 18
  • 19
13
votes
3 answers

Can't downgrade database from version `n` to `n-1` on Samsung

I have an application with a database, created and opened using the standard SQLiteOpenHelper. Whenever I upgrade the database version, I also upgrade the application's version code, so there is no way for the database to go down (the database…
XGouchet
  • 10,002
  • 10
  • 48
  • 83
13
votes
2 answers

Concurrent writing to android database (from multiple services)?

I've a serious problem with android sqlite database and concurrent writing. For better explanations, I will give you a real life example: I've an desktop widget, where I'm showing a list of items from my database (and on background I have…
qkx
  • 2,383
  • 5
  • 28
  • 50
12
votes
3 answers

Android SQLite SQLiteOpenHelper IllegalStateException - DB Already Closed Error

This has been driving me crazy for a few days now. I have an android application that is pretty complex. It uses multiple threads to pull data from a server and populate the SQLite database. I'm using a singleton to reference my extension of…
SBerg413
  • 14,515
  • 6
  • 62
  • 88
11
votes
7 answers

SQLiteOpenHelper - how is the database created?

I'm making a database application, and my program works and I've understood most of the tutorial I've been following. However, one aspect remains unclear to me. There is an inner class of MyDBHelper extending SQLiteOpenHelper. Outer variables…
Tim
  • 1,056
  • 4
  • 17
  • 34
11
votes
2 answers

What is the Default Threading mode of SQLite in Android?

http://www.sqlite.org/threadsafe.html From above link I came to know, SQLite support three different threading modes : Single-thread,Multi-thread and Serialized. I am just curious to know "What is the Default Threading mode of SQLite in Android"? is…
Ganesh K
  • 2,623
  • 9
  • 51
  • 78
10
votes
2 answers

"There is no default constructor available in android.database.sqlite.SQLitepenhelper" in Android Studio

Trying to extend class with SQLiteOpenHelper, but this error shows up : "There is no default constructor available in android.database.sqlite.SQLitepenhelper" along with other "cannot resolve symbol Category, Note,..." class DbHelper extends…
PTG_Sa
  • 101
  • 1
  • 1
  • 3
10
votes
4 answers

SQLite connection object leaked - Android

I am making my first android app, and I took some sqlite tutorials first, that taught me to use a databaseHelper that extends SQLiteOpenHelper. So my databaseHelper does extend SQLiteOpenHelper. I get a sqlite connection leak warning in the Logcat…
user3164083
  • 1,053
  • 6
  • 18
  • 35
10
votes
5 answers

Android Pushing Updates on Play Store

I have an app that depends on SQLite for data which is populated by xmls shipped with the app in the assets folder. When you run the app the first time it sets a shared preference config_run = false. then i check if config_run = false then parse…
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
9
votes
5 answers

net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master

Error this line : mDataBase = SQLiteDatabase.openDatabase(dbPath, "123", null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); When open the database . but whats Wrong? how to open database with password? Can any one help me? I set the password on…
9
votes
5 answers

SQLiteOpenHelper synchronization

So I've come up with some idea and I'm wondering if it is realizable. Let's say I've multiple tables(database models) each of them is represented by some class.I don't wont to use singleton pattern with the open helper so I've created some simple…
Teodor
  • 300
  • 1
  • 13
9
votes
1 answer

Confused regarding SQLiteOpenHelper and creating multiple tables

I feel the Android developer guidelines regarding saving data in SQLite is really lacking. I'm confused as to what the general guideline is when it comes to multiple tables. I currently have two Managers that expose (CRUD) two different sets of…
ndsc
  • 1,173
  • 2
  • 13
  • 22
8
votes
3 answers

Android AsyncTask and SQLite DB instance

I have a problem and I am not sure how to approach it. An activity in my app has multiple AsyncTasks which access single SQLiteOpenHelper. I initialize and open the helper in onCreate() and I am closing it in onStop(). I also check if it has been…
Marqs
  • 17,800
  • 4
  • 30
  • 40
1
2
3
53 54