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

SQLiteOpenHelper getInstance() Method Throws Null Pointer Exception

I have a DatabaseHelper class as part of my app (a snippet is below): public class DatabaseHelper extends SQLiteOpenHelper { private static final int VERSION = 1; private static DatabaseHelper mInstance; // Get database instance public static…
mercer721
  • 103
  • 1
  • 9
3
votes
1 answer

Creating database table on runtime in sqlite

as I am new to android programming, I am creating a Table and naming it with the text in edittext. how can i do it. searched questions but did not get any answer. And my application needs to create many tables at run time. i am using…
Shuddh
  • 1,920
  • 2
  • 19
  • 30
3
votes
2 answers

Helper.getWritableDatabase() function

I'm working on my first SQLite database app and because I'm stuck for a long time I decided to ask about it online. I have trouble with running the application I that have written, because of the function: Helper.getWritableDatabase(); without it,…
YanivGK
  • 893
  • 12
  • 18
3
votes
3 answers

onUpgrade is not being called at first time in android SQLiteOpenHelper

I am facing a very strange problem. I am developing an android application that has an sqlite DB as its database. I am using DBAdapter class which extends SQLiteOpenHelper. I have searched on internet but can't find a solution. Here is my…
Raj
  • 496
  • 7
  • 27
3
votes
0 answers

attempt to re-open an already-closed object: SQLiteDatabase by getReadableDatabase

I've followed this tutorial: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ to make my app read from an existing database. The database has been copied to the /data/data/package/databases/ successfully, but I…
Dennis
  • 2,271
  • 6
  • 26
  • 42
3
votes
1 answer

android.database.sqlite.SQLiteException: no such column : id (code 1) while compiling : s

following error found when I click on "Insert" button Error Found :android.database.sqlite.SQLiteException: no such column : id (code 1) while compiling : select id,student_name, student_rollno FROM studentTable WHERE idrh Error Found…
3
votes
1 answer

Why in a test class that extends AndroidTestCase, does getContext() return null?

I have my own SQLiteOpenHelper as follow : public class MyOpenHelper extends SQLiteOpenHelper { public static final int DB_VERSION = 1; public static final String DB_NAME = "dbname"; public MyOpenHelper(Context context) { super(context,…
blue_diamond
  • 65
  • 3
  • 8
3
votes
3 answers

how to create database once only, then read and write multiple times from it, SQLite, OpenHelper, Android

I made two classes, the main class that extends Activity and the Database class that holds the database and it's methods. parts of the code from the database class are shown below. the SQLiteOpenHelper class is a nested class inside the database…
Kevik
  • 9,181
  • 19
  • 92
  • 148
3
votes
2 answers

"Table X has no column named Y" error inserting data into a SQLite database

I got an error on inserting data on my database. 01-28 20:59:06.277: I/Database(553): sqlite returned: error code = 1, msg = table tableKo has no column named phone 01-28 20:59:06.309: E/Database(553): Error inserting phone= email= address=…
3
votes
3 answers

Getting ArrayList with SQLOpenHelper not working

I have a problem with my SQLiteOpenHelper class. I have a database with printer manufacturers and details of any kind of printer. I try to get all manufacturer from my database with this code and returning them in a arraylist. // Read database for…
Katamave
  • 35
  • 1
  • 8
3
votes
3 answers

No database created after done changes in SQLite Database

can someone help in SQLite database in android? First all,i have using tutorial from here. It works well in my application but when i added new column and change database version to '2', the application stopped and in the file explorer, no database…
3
votes
1 answer

SQLiteOpenHelper and CRUD Operations

In most Android database examples, SQLiteOpenHelper is extended and contains information to create and update the database. However, in many examples the helper class contains methods to add, delete, and return records. My question is would it be…
Singularity222
  • 317
  • 4
  • 18
3
votes
2 answers

Passing Context to SQLiteOpenHelper

First up, I am new to android apps and am not working solo on this. My team mate has taken design while I handle this, and asked me to set up the database and the method to do this, etc etc. So while most of this seems to be ok, I put: Context…
James Sunderland
  • 135
  • 1
  • 1
  • 13
3
votes
2 answers

Concurrent access to a SQLite database in Android - db already closed

I read a lot of topics on this subjet but no one could answer my question. I access my database from concurrent threads, my SQLiteOpenHelper implements the design pattern of the singleton so I have only one instance for my app. I access my database…
Fr4nz
  • 1,616
  • 6
  • 24
  • 33
3
votes
3 answers

Application Class with Database Trouble in Android

I'm having trouble accessing a SQLite DB in my Android application. I have created an application class that contains an instance of a SQLiteOpenHelper however whenever I try to open the DB in another activity, it crashes. Here is my application…
Seuby
  • 77
  • 1
  • 8