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

Android: What is the best place to create SQLite database and tables

I have to create nearly 5-6 tables in my android application. What is the best place to create SQLite database and 5-6 tables? I can write all these logic(Using SQLite open helper methods) when initial activity launch, but if i do that it will be…
0
votes
4 answers

Why am I getting a _id does not exists error when only trying to query one column from a table?

I was trying to solve the question on why I was getting this error yesterday with some code: java.lang.IllegalArgumentException: column '_id' does not exist I had a lot more code, especially that I did not need, so I stripped a lot of it out to…
Andy
  • 10,553
  • 21
  • 75
  • 125
0
votes
0 answers

"database not open" when db is closed by different writer

I have many Fragments in a ViewPager in my app. At the start of the application three of them try to connect to database to retrieve data. For database handling I use a singleton pattern with SQLiteOpenHelper. When I need my database I call it like…
Michał Klimczak
  • 12,674
  • 8
  • 66
  • 99
0
votes
2 answers

My Android SQLite DB query doesn't return newly inserted data until I exit my activity and restart

I'm using a SQLite DB in my android application to store football players and maintain which rosters they belong to. The activity which manages these rosters has the ability to open 2 dialog windows, 1 to save the current roster to the db and 1 to…
Arutal
  • 35
  • 5
0
votes
1 answer

Android SQLite DatabaseObjectNotClosedException

In a PoC Android app I'm building, I'm getting an android.database.sqlite.DatabaseObjectNotClosedException when garbage collector is being called on the app on close. This is happening even when I'm invoking the close method on both the…
Debojit
  • 568
  • 1
  • 10
  • 24
0
votes
3 answers

IllegalStateException in ListView.OnItemClickListener

I have a listview in my main activity which shows the detail info about a person when we click on it and I have two classes EmployeeList.java - http://pastebin.com/5vPMKrCQ DatabaseHelper.java - http://pastebin.com/NS7RR8E6 I have the following…
Satheesh
  • 646
  • 1
  • 10
  • 33
0
votes
1 answer

Lists rearrangement after finishing a query

Creating a searchable contacts kind of app. Below is my code public class EmployeeList extends Activity { protected EditText searchText; protected SQLiteDatabase db; protected Cursor cursor, listcursor; protected ListAdapter…
Satheesh
  • 646
  • 1
  • 10
  • 33
0
votes
1 answer

Failing to populate ListView via Simplecursor Adapter

I want to populate my listview with the data from my database,but when i try to do that it just gives me one exception i.e. "04-27 13:15:51.139: E/AndroidRuntime(2575): Caused by: java.lang.IllegalArgumentException: column '_id' does not exist" No…
0
votes
3 answers

Create Sqlite database with 8000 records

I'am developing an application which uses sqlite for autocomplete textview. The database has more than 8000 records. Creating a database can be done with a query in onCreate(). But how do i create a database with 8000+ records in it. writing insert…
Jeyanth Kumar
  • 1,589
  • 3
  • 23
  • 48
0
votes
3 answers

Android + sqlite insert speed improvements?

I recently inherited a project where a sqlite db is stored on the users sdcard (tables and columns only, no content). For the initial install (and subsequent data updates), an XML file is parsed via saxParser storing it's contents to the db columns…
worked
  • 5,762
  • 5
  • 54
  • 79
-1
votes
1 answer

Kotlin SQLiteOpenHelper failing to insert data into table

class SQLiteHelper(context: Context?) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION){ companion object{ private const val DATABASE_VERSION = 1 private const val DATABASE_NAME = "notes.db" private const val TBL_NOTES =…
ISO
  • 11
  • 2
-1
votes
1 answer

facing issue in login and registration in android studio using SQLite + kotlin

I try to login. after registration had done. When I try to login it shows invalid password and username. But, I mention the correct password and username github file package com.example.app import android.content.Intent import…
-1
votes
1 answer

Data Registration to database and validation from database Sqlite won't work

I've got this Sqlite database named DatabaseHelper and i need to register the data (username, pass, email, and phone) i need to check if username already exists when button register pushed and check user and pass data at login activity. Here is my…
suppatra
  • 17
  • 4
-1
votes
1 answer

How can I view the details of the user who is currently logged in

Am developing an android application in java android studio. I need to collect the details of the user who is currently logged in. I don't seem to find any help online. I have tried using the code below, but it is not working [[1]:…
festus
  • 1
  • 1
-1
votes
1 answer

Replace column names with placeholder in sqlite

Can I replace a column name with a placeholder in while querying data from a table in sqlite? Example: db.execute("SELECT ? FROM currency WHERE user_id = ?", ( "usd", 1).fetchall() It returns the placeholder which is 'usd" or any string I replaced…