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

getWritableDatabase() instance throughout the application lifecycle

I have made Singelton object to make queries to SQLiteOpenHelper in which I have saved instance of getWriteableDatabase(). Throughout the application lifecycle, for all select and insert/update queries I am using that instance from multiple…
1
vote
1 answer

Auto increment is not working in SQLite database

I am working in sqlite database. I have a product table which has a product id, name, price, and a company id I made to be the primary key and autoincrement when I add products to the database, but productid seems to be empty Here's a screenshot of…
Abd EL Magied
  • 141
  • 2
  • 9
1
vote
1 answer

E/SQLiteLog: (1) no such table: sample

DatabaseHelper public class DatabaseHelper extends SQLiteOpenHelper { public static final String DBNAME = "sample.sql"; public static final String DBLOCATION = null;/*"/data/data/com.example.final_view.database/databases/"*/ public static final int…
Junggyun Ann
  • 31
  • 1
  • 2
1
vote
1 answer

Is there a reason not to return an initialized ArrayList of MyClass from SQLiteOpenHelper DB class rather than a Cursor?

For simplicity, lets say I have the following class object and DB classes in my Android app: public class MyObject{ private String title; private double number; } public class MyObjectDB extends SQLiteOpenHelper { public static final…
RB2017
  • 81
  • 3
1
vote
3 answers

AndroidDev: SQLite - Displaying values from DB into TableLayout?

I am working on an Android App for learning and it is based on the user being able to add their Pill/Medication, and then go to a 'Schedule' page where they can see the dosage and check if they have taken each dose. I believe I have a successful Add…
1
vote
1 answer

Android SQlite - Working with Dynamic tables

I am building an Android native mobile application and I need to create tables dynamically with user input in my Application. By reading the documents, it looks like I cannot use SQLiteOpenHelper since Table needs to be created only in constructor…
Joseph
  • 1,060
  • 3
  • 22
  • 53
1
vote
3 answers

Sqlite database query based on a string name

I created sqlite database inside my app and trying to save highlighted text , Saving is all working fine , even retrieving all highlights is working fine , but when I query for highlights based on bookname I am getting an error. Here is what I tried…
Manohar
  • 22,116
  • 9
  • 108
  • 144
1
vote
0 answers

Different behaviors of SQLiteOpenHelper on different Android API levels

I have two android phones, which are Sumsung Galaxy s3 (Android 4.4.2, Kitkat, API19), and Nexus 6p(Android 6.0.1, Marshmallow, API23). Here is my DatabaseHelper class: public class DatabaseHelper extends SQLiteOpenHelper { private static final…
Leon
  • 811
  • 10
  • 21
1
vote
0 answers

Android Sqlite failed to open database (not an error)

I am currently programming an Android app where I have to use a SQLite database. At some point it happens that the database (with data stored in it) cannot be opened anymore and the app crashes and I cannot open it up again. When I reinstall the app…
Jonas
  • 13
  • 1
  • 4
1
vote
1 answer

get specific row in SQLiteDatabase not working

im a new developer and noob in SQLiteDatabaseand and have this little problem .. and i need a little help I'm creating a simple to_do app that have catagories, the app can create catagories and display them in a list view, and by clicking the…
danny
  • 147
  • 1
  • 15
1
vote
1 answer

Handling SQLite singleton instances and its Context dependency in Android

I am currently working on an Android project that performs a lot of communication with the SQLite database. I am also trying to implement a MVP framework within the app. My current implementation of the Singleton instance is similar to the…
Llama.new
  • 357
  • 8
  • 23
1
vote
0 answers

2-D String Returning null value after returning from function(android)?

I am implementing SQLite in android to get all the rows data using 2-d strings. But the strings are giving me a null value except for the value of the last index Code I wrote to get all the data of table public String[][] getAllData(){ …
1
vote
1 answer

How can I update a single (or multiple, but not all) columns in an SQLiteDatabase?

I use a SQLitDatabase for my project, which I normally update by: Getting all the values one row contains (let's say v1, v2 and v3) Putting all the values back, and replacing the ones I need to be updated. Example: I want to update…
Timmiej93
  • 1,328
  • 1
  • 16
  • 35
1
vote
1 answer

Execute Query in android searching if a string is contained inside the string inserted in a column

I have a database in an android app and the following are its columns: public class DBhelper extends SQLiteOpenHelper { public static final String COL_TIPO = "ColonnaTipo"; public static final String COL_DIFFICOLTA="ColonnaDifficolta"; …
SctALE
  • 509
  • 2
  • 10
  • 30
1
vote
2 answers

sqlite database not getting update

I'm going to update my database through below code: this is the way I am using to do that. I don't know should I have to call create database method when I want to connect to db: public int addDBfav(int id) { SQLiteDatabase…
Jumong
  • 125
  • 12