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

Can i share one sql database with SQLiteOpenHelper in android with two apps?

I have two applications. One is main worker and other one is watchdog. I want to check first clock with other one... (clock is just incrementing number in DB record)... so I'm writing clock status in DB with SQLiteOpenHelper and want to check it…
Kaki Tk
  • 31
  • 1
  • 7
1
vote
1 answer

SQLiteDatabase.update doesn't affect rows

I'm trying to update multiple rows using SQLiteDatabase.update on certain table. Code to execute query: public void onJobStart(int fileType) { ContentValues cv = new ContentValues(); cv.put(Contract.Entry.UPLOAD_STATUS, STATUS_READY); …
sharonooo
  • 684
  • 3
  • 8
  • 25
1
vote
2 answers

Android SQLiteOpenHelper Error - Call to super must be the first statement in contructor

Let me start by saying that before asking this question, I have already read many similar questions, but I couldn't find any possible solution for my situation. I am trying to extend SQLiteOpenHelper class, but with 2 significant differences - I am…
Dr. Atul Tiwari
  • 1,085
  • 5
  • 22
  • 46
1
vote
1 answer

Insert only if timestamp is unoccupied

I am using Android / Java and SQLite3 / SQLiteOpenHelper, with the Cursors and ContentValues. I have a timestamp field in my table. I want to ensure that if someone is adding a new row, the row is not added if the timestamp is already occupied (so I…
The 29th Saltshaker
  • 671
  • 1
  • 6
  • 16
1
vote
1 answer

Android SQLiteOpenHelper OFFSET

I have SQLiteOpenHelper Database in my android app. On PC where i have derby database, i use this sql order. SQLiteDatabase db = this.getWritableDatabase(); String sqlOrder = "SELECT * FROM " + TABLE_NAME + " ORDER BY ID ASC OFFSET 40 ROWS"; …
Deren
  • 85
  • 1
  • 7
1
vote
1 answer

Android SQLiteDatabase Table

I am working on an android app and I have a problem i can't solve. I hope you guys can help me. I get this error: android.database.sqlite.SQLiteException: table FBFriends has no column named id (code 1): , while compiling: INSERT INTO…
StijnB
  • 79
  • 9
1
vote
1 answer

SQLiteOpenHelper : OnCreate Function not called

OnCreate() not called even after calling getWritableDatabase() in the constructor package com.example.user.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends…
Ronak Mutha
  • 304
  • 1
  • 2
  • 13
1
vote
1 answer

Strange SQLite Errors on Samsung Lollipop Devices

For the past three days I am unable to understand what issues are being faced. I am getting nulls for some variables and not for others, or sometimes for all. The problem is specifically being faced on Samsung Devices running Lollipop. What I am…
1
vote
1 answer

android: Why close SQLite db cursors although they will close at their finalize methods?

I build an app that uses SQLiteOpenHelper and I see that the cursor objects I received from the queries are closing themselves in their finalize methods. I know it's not recommended to rely on the finalize method but if I'm working right and not…
Bokris Itzhak
  • 911
  • 9
  • 30
1
vote
1 answer

Do I need call close() when I use getWritableDatabase()?

If I have code like this private final SQLiteDatabase database; private final SQLiteOpenHelper helper; // ... this.database = helper.getWritableDatabase(); // ... Do I need to call close() explicitly? I am confused by this answer:…
xskit
  • 421
  • 1
  • 8
  • 20
1
vote
1 answer

I am trying to configure a simple DbHelper, and getting an error while executing the same

When ever i try to debug the app on my phone this error occurs... I cannot figure out what is the problem? The Error Is:MY LOGCAT WINDOW My DatabaseHelper class package com.example.adityasinh.healthassitance; import…
1
vote
1 answer

How to delete a row in SQLiteDatabase - Android Content Provider

I’m struggling to write a method that deletes a row from the SQLiteDatabase. I have a list of songs in a gridview where when a user clicks one of the items from the list the app will take them to my SongDetailFragment activity which contains more…
1
vote
1 answer

Syntax to create unique composite column - Android SQLiteOpenHelper

I have this onCreate method in my SQLiteOpenHelper class, and I would like to add a unique constraint on these two columns (composite unique columns): SongContract.SongEntry.COLUMN_TITLE SongContract.SongEntry.COLUMN_RELEASEDATE But I am getting…
D. Ace
  • 398
  • 4
  • 9
  • 25
1
vote
1 answer

Populating ListView from external SQlite database queried with a SearchView widget - Android

I am trying to display data from my database in a ListView widget. The database is queried using a SearchView widget. Here is the code for my SQlite open helper class: import android.content.Context; import android.database.Cursor; import…
1
vote
1 answer

cannot resolve symbol 'context' when Accessing database from multiple activities using Singleton

I've been attempting to implement the use of a database in my application using a tutorial on YouTube: https://www.youtube.com/watch?v=T0ClYrJukPA. But ran into the problem of trying to access my database from multiple activities. A question on…
Matt
  • 81
  • 2
  • 11