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

In Android , how to use the condition based on the sum of 2 columns' values operation in the where clause using SqliteDatabase 's query() method

I need to execute query in Android using SqliteDataBase's query() method. I need to get rows which depends on 2 columns' combined condition. I tried the following code : String whereClause = " colA = ? and (colB + colC*100) >= ?"; String[] values =…
Shadab Ansari
  • 7,022
  • 2
  • 27
  • 45
2
votes
1 answer

SQLiteOpenHelper not calling onCreate

This is the fist time I've used SQLiteOpenHelper (or databases on android). When I get a writeable database I was wondering why onCreate isnt being called on each new instance of the class. Am I doing something wrong? public class DatabaseHelper…
Jon Wells
  • 4,191
  • 9
  • 40
  • 69
2
votes
1 answer

FOREIGN KEY constraint failed (code 787) [NO ANDROID ROOM]

I have an Android Project on Android Studio with a DataBase which has 3 tables, and one had two FK. I think I saw every code with a solution and any work for me. This is the error: E/SQLiteDatabase: Error inserting…
2
votes
2 answers

Problem in inserting primary Key in table

I have 2 tables, corporate (Used to store Login info), and assignment (used to store assignment details). Columns in Corporate table: id(Primary key autoincrement), uname,password. Id is not taken from the user. Columns in assignment table:…
akm
  • 149
  • 1
  • 9
2
votes
1 answer

Code 14: Unable to open database

I know this question has been asked before. But, the problem is, the same code (for database handler) is working for another app, but not the one I'm currently working on. I've even made sure the permissions are given by checking the permissions in…
Dante
  • 457
  • 1
  • 5
  • 17
2
votes
2 answers

not able to retrieve data from an SQLite database on android. (returns an empty ArrayList)

I got a problem in trying to extract data from SQLite database, I am trying to create an android app that serves as a Question Bank. when trying to Retrieve information from this Database I get an empty list of Questions the app runs quite well with…
Matrix Boy
  • 41
  • 2
2
votes
1 answer

Android Studio search existing sqlite db

So im developing an app and I want the user to search for a food item in my database and then to be returned with a list view of all food names that match the search criteria. I already have my slqite database created and added to the assets folder.…
user7262674
2
votes
3 answers

Exception- Writing exception to parcel

This is a small assignment to insert simple text data to sqlite database. I have used SQLiteOpenHelper class for this and used given code. I've found some similiar questions here but not the exact same. Please help me out. Here is the…
Wijay Sharma
  • 439
  • 7
  • 17
2
votes
2 answers

Using SQLiteOpenHelper to run statements from SQL

When I try to insert short portions of my data by copying over the relevant SQL statements into a String variable containing the SQL statements that SQLiteOpenHelper must run, everything works fine. Here is my query: String POPULATE_TABLE = …
Shahraiz T.
  • 338
  • 4
  • 13
2
votes
0 answers

Android SQLiteOpenHelper save custom object with object variable

I'm using SQLiteOpenHelper for saving data to the db in my Android app. I want to save custom object that has another custom object as variable. Sample of the object: public class Device implements Serializable { public String deviceId; …
Stepan Sanda
  • 2,322
  • 7
  • 31
  • 55
2
votes
1 answer

SQLiteOpenHelper constructor is not being called

I am creating an app using the SQLiteOpenHelper. When I create an object for this class, the constructor is not being called which results in a NullPointerException when I use it's methods. Here is my DatabaseHandler class: class DatabaseHandler…
2
votes
1 answer

Duplicate Column Name lock_status

I have added lock_status column in database and in onUpgrade() Alter Table,but When I try to open my App, it force stops with the following error. What should I do in onUpgrade(), I have updated my database 4th time with new column. Help is highly…
2
votes
1 answer

Removeing from SQLite database takes a long time, causing hangs

I use a SQLite Database in my app. For a specific action, I want to remove multiple (could be quite some, up to approx. a hundred) entries in a specific table. I have tried doing this by calling deleteStuffLink() as many times as needed in a for…
Timmiej93
  • 1,328
  • 1
  • 16
  • 35
2
votes
1 answer

How to let greenDAO to create the Database on sdcard ? - Android

I want to use greenDAO as sqlite DB ORM but my database should be located on sdcard in a specific folder like /sdcard/myapp/database.sqlite So how to choose the folder of database to be created in using greenDAO ?
MBH
  • 16,271
  • 19
  • 99
  • 149
2
votes
1 answer

How to open SQLite database on DB Browser for SQLite(No emulator)

I have been looking for hours now how to see my database using the program DB Browser for SQLite (http://sqlitebrowser.org/). I downloaded the software and i can't find any file on my computer that can be opened with this software. So what kind of…
God
  • 1,238
  • 2
  • 18
  • 45