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
1
vote
2 answers

Activity life cycle and database confusion

I have an activity where I am opening an database by calling constructor of SQLiteOpenHelper. dbHelper = new DBHelper(this); //DBHelper class extends SQLiteOpenHelper Then on click of a button I am opening another activity and closing the…
Sush
  • 6,839
  • 1
  • 18
  • 26
1
vote
1 answer

update embedded sqlite mac address database android on button click

I have an embedded database file(Macs.db in assets directory) of MAC addresses in my application.The database is a very simple sqlite database with just one table. The table named mactoname has two columns: 1. macaddress, 2.name. There are some…
kzs
  • 1,111
  • 5
  • 20
  • 35
1
vote
2 answers

Extended SQLiteOpenHelper class calls onCreate every time?

public class DatabaseHelper extends SQLiteOpenHelper { private static final String DB_NAME = "test.db"; private static final int DB_VERSION = 1; private boolean DB_JUST_CREATED = false; private Context _context; public…
soren.qvist
  • 7,376
  • 14
  • 62
  • 91
1
vote
1 answer

Android Spinner with SQLite Database

I have used MyOnItemSelectedListener to populate items into the Spinner and it works. My problem is after this how to set the Database details in a a list view below Spinner. What code should be written in after onItemSelected?
1
vote
1 answer

super.getWritableDatabase() crashes when called from MyApplication that's in Library Project

I do have several apps that are designed the same way. An extended Application holds the database connection and an extended SQLiteOpenHelper has all the code. This works when used in a standard android project. It crashes when the extended…
Harald Wilhelm
  • 6,656
  • 11
  • 67
  • 85
1
vote
1 answer

DatabaseObjectNotClosedException

I've noticed that there are several question on this exception. But they do not solve my problem. I have a databaseHelper class that has a inner class that extends SQLiteOpenHelper: private static class OpenHelper extends SQLiteOpenHelper { …
johan
  • 6,578
  • 6
  • 46
  • 68
1
vote
1 answer

Android Distribute ContentProvider as a library bundled with app

I am working on a set of novelty applications that share their fundamental behavior (picking random words from a database and combining them). Because they all work BASICALLY the same, I tried to treat the base of the code as a template of some…
1
vote
0 answers

How do I insert initial data in a SQLite database table?

I'm currently trying to create an Flashcard application, in which the user can either create his own cards/notes or use pre-defined cards. The idea is to have around 500 to 1000 cards to be inserted on the database right after its creation. But how…
1
vote
0 answers

Upgrading from java-based android app to react native and SQLite storage

I believe there is only one location databases can be stored on Android but also wondering if the file extension for SQLiteOpenHelper is .db3, .db, or user defined and if not defined there is no extension. Any help? My scenario is: I have a java…
1
vote
1 answer

How to browse android room database when using RequerySQLiteOpenHelperFactory

For my current Android application I am employing this version of Android Studio Android Studio Dolphin | 2021.3.1 Canary 9 Build #AI-213.7172.25.2113.8473230, built on April 19, 2022 Runtime version: 11.0.13+0-b1751.21-8125866 x86_64 VM: OpenJDK…
Hector
  • 4,016
  • 21
  • 112
  • 211
1
vote
0 answers

Android Studio error, column name doesnt exit even though it is created?

This is the error i am encountering : E/SQLiteLog: (1) table contacts has no column named name in "INSERT INTO contacts(phone_number,name) VALUES (?,?)" E/SQLiteDatabase: Error inserting phone_number=22222 name=Name And here the code running the…
1
vote
0 answers

What happens if I replace the underlying sqlite database when a SQLiteOpenHelper has opened the database?

What happens if I replace the underlying sqlite database when a SQLiteOpenHelper has opened the database? I suppose somehow the helper is operating on a file-descriptor. Can it break if I replace the sqlite file underneath? I have taken read/write…
JohnyTex
  • 3,323
  • 5
  • 29
  • 52
1
vote
1 answer

How to reset an application states when upgrading from the market

As a developer, I have applications already published on the market. When users download the new version, I want the application to clean its states ( SharedPreferences , SQLite schema ... ). I read about SQLiteOpenHelper. I suppose when I'm loading…
Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110
1
vote
0 answers

How to prevent app crash on SQLiteOpenHelper onUpgrade fail

If there is an error during the onUpgrade method of my extended SQLiteOpenHelper class, the app crashes. I'd instead prefer to let the app continue opening the database and disable certain features that depend on the new schema. I achieved it as…
Shahid Thaika
  • 2,133
  • 5
  • 23
  • 59
1
vote
1 answer

In my SQliteDatabase date is not createing (Kotlin)

I have a SqlitieDatebase in android studio and for some reason, the database is not creating. I really like it if someone can help me with this issue. I am not getting an error t all for the database. Thank you for your help This is my code for just…