sqliteopenhelper

java - java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow

白昼怎懂夜的黑 提交于 2019-11-30 05:09:06
问题 I'm creating an app which uses SQLiteDatabase to store items of a ListView . But, I get an error while populating the data in the ListView from the Database, and the app crashes. Here's my Database - import java.util.ArrayList; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class NotesDatabase

Insert JSON data into the SQLite database in android

给你一囗甜甜゛ 提交于 2019-11-30 04:00:49
I want to insert the data from JSON array into the SQLite database. I have created two classes CategoryHelper.java and AndroidJSONParsingActivity.java to get the java response. When I run the code got the exception in databaseHelper.saveCategoryRecord(id,name); My API is working fine and giving me the data. My code is below: CategoryHelper.java package com.androidhive.jsonparsing; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class

SQLite connection object leaked - Android

泄露秘密 提交于 2019-11-30 02:16:34
I am making my first android app, and I took some sqlite tutorials first, that taught me to use a databaseHelper that extends SQLiteOpenHelper. So my databaseHelper does extend SQLiteOpenHelper. I get a sqlite connection leak warning in the Logcat so would like some advice about what to do to fix that. I get this error: 02-01 21:39:50.740: W/SQLiteConnectionPool(32061): A SQLiteConnection object for database '/data/data/com.btf271.fashionassistant/databases/clothingManager' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no

Android SQLite SQLiteOpenHelper IllegalStateException - DB Already Closed Error

烈酒焚心 提交于 2019-11-30 01:27:48
This has been driving me crazy for a few days now. I have an android application that is pretty complex. It uses multiple threads to pull data from a server and populate the SQLite database. I'm using a singleton to reference my extension of SQLiteOpenHelper. I'm opening and closing the database in each of my activities. The error ONLY occurs in a situation when I'm 4 activities deep and then try to back out. I've tried various ways of opening and closing the database, including moving the close from the onDestroy() to the onPause() methods and also adding another open to the onResume(). Also

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

老子叫甜甜 提交于 2019-11-29 02:42:41
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 with code like this : SQLiteDatabase db = DatabaseHelper.getInstance().getWritableDatabase(); ... Do some update in the DB ... db.close(); I don't understand why I still get "db already closed" error, shouldn't the getWritableDatabase() method lock the database until close() is called ? Other getWritableDatabase() calls from other threads should

Android SQLiteException: Failed to change locale for db to 'en_US'

无人久伴 提交于 2019-11-29 01:25:17
I recently updated one of my (open-source) Android apps and my users are getting an exception that I can't replicate. The key parts are : android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5) and then Caused by: android.database.sqlite.SQLiteException: Failed to change locale for db '/data/data/com.airlocksoftware.hackernews/databases/hacker_news_cache.db' to 'en_US'. This is happening on devices with Android 2.3 - 4.2.1, and in multiple places within the app where I try to connect to a database. I am closing the database after I use it. I can't find much

SQLite connection object leaked - Android

落花浮王杯 提交于 2019-11-28 23:59:20
问题 I am making my first android app, and I took some sqlite tutorials first, that taught me to use a databaseHelper that extends SQLiteOpenHelper. So my databaseHelper does extend SQLiteOpenHelper. I get a sqlite connection leak warning in the Logcat so would like some advice about what to do to fix that. I get this error: 02-01 21:39:50.740: W/SQLiteConnectionPool(32061): A SQLiteConnection object for database '/data/data/com.btf271.fashionassistant/databases/clothingManager' was leaked! Please

Backup Room database

人盡茶涼 提交于 2019-11-28 19:36:05
I'm trying to backup a room database programmatically. For that, I'm simply copying the .sqlite file that contains the whole database But, before copying, due to the fact that room has write ahead logging enabled, we must close the database so that -shm file and -wal file merge into a single .sqlite file. As pointed out here I run .close() on RoomDatabase object: Everything works fine with the backup, BUT, later on, when I try to execute an INSERT query, I get this error: android.database.sqlite.SQLiteException: no such table: room_table_modification_log (code 1) How can I properly re-open

Best option to store username and password in android app

半腔热情 提交于 2019-11-28 17:49:21
I am developing an app where user needs to sign in to perform operations...but mostly on android handset ppl use "keep me signed in"...and in tht case I'll have to maintain the value of username and password within my app..should I use preferences, or SQLite Db or is there something else and how can I make it secure? Plz Help... Thanks in advance.. Yes, this is tricky on Android. You don't want to store the plaintext password in the preferences, because anyone with a rooted device will basically be displaying their password to the world. On the flip side, you can't use an encrypted password,

When should I call close() on SQLiteOpenHelper used by ContentProvider

♀尐吖头ヾ 提交于 2019-11-28 08:26:01
In my android app, I use SQLiteOpenHelper to implements ContentProvider. Query, add, delete operations are all through ContentProvider. But in one of my android phone(htc g13), I found *.db-wal file in directory /data/data/[package name]/databases. And the file size increate very fast when operating with ContentProvider. It occupied user RAM space too much. It is recommended to close the SQLiteOpenHelper to solve my problem (it is useful) in post enter link description here . But I want to find a "place" to add the "close()" method since I am not using SQLiteOpenHelper directly (using through