Tag: sqlite

Sqlite database lifecycle? It is deleted when the app is closed?

I’m following a simple tutorial that creates a class wich extends from SQLiteOpenHelper and creates a DB with one table and 5 rows. OK, but I need to understand some more about android Sqlite databases. For example, what happens if the app is closed or the phone is off? Is the database deleted? Thanks

Change the primary key of a table in SQLite

I have the following table: [id,lang,data] Where the primary key is id I want to change the primary key to id,lang without losing the content of the table. What is the query I must run to change it Thanks

Android SQLite INSERT

I am using execSQL on SQLite database. The sql INSERT strnig is INSERT INTO Tasks (_id, Aircraft, Station, Discrepancy,DateCreated, CreatedBy, Status, DateClosed, ClosedBy, ArrivalFlightID, RecordChangedByUI) VALUES (‘271104′,’ ‘,’ORD’,’Critical Flight (0496/28)’,’9/4/2011 6:57:00 PM’,’SYSTEM’,’NEW’,”,’null’,’0′,’N’) Table is “create table Tasks (_id integer primary key, ” + “Aircraft text null, Station text null, Discrepancy text null, DateCreated text null, […]

Insert JSON data into the SQLite database in android

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; […]

android.database.CursorWindowAllocationException when moving a Cursor

I’am using an SQLite database and I regularly get runtime errors I can’t find the origin of. After a query, I use moveToFirst to point on the first record retrieved and this sometimes triggers an android.database.CursorWindowAllocationException exception. Added to this exception is the following sentence : “Cursor window allocation of 2048kb failed.# open Cursors=736 (#cursors […]

attempt to re-open an already-closed object: SQLiteDatabase:

I’m trying to delete something from a database then insert a new value. I don’t know much about databases, so would appreciate advice on whats going wrong here. I keep getting the following error: Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: Its called from an async task, works fine the first time, […]

onUpgrade() sqlite database in Android

I created an Android application which, check at startup if there is a new version of application. If yes, the application download the new apk file and over-install new apk. My application use the sqlite db. But this db, from one version to other can change. I think I have to use the method: onUpgrade() […]

CursorIndexOutOfBoundsException Index 0 requested, with a size of 0

I’m trying to get a text from a certain row of my database. For this, I made this function public String getTranslation(long rowId) throws SQLException { String str = null; Cursor mCursor = db.query( true, TABLE_LANGUAGE_FR, new String[] { KEY_ID_INTERFACE_TEXT, KEY_ITEM_NAME,KEY_FORM_LABEL_ID, KEY_FORM_RANK }, KEY_FORM_LABEL_ID + “=” + rowId, null, null, null, null, null ); if […]

ActiveAndroid SQLite exception 'No such table'

I’m having a problem with active-android. I at trying to fetch user location, number of passengers and general direction. I want to save these to phone storage in a table called “Splits” using activeAndroid. But whenever I call the save() method i get a long list of errors. I have tried to reinstall the app, […]

getWritableDatabase called recursively

I’m attempting to update my database table with the following code: public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { String query = “ALTER TABLE names ADD COLUMN hidden integer default 0”; dbHelper.getWritableDatabase().rawQuery(query, null); } However, when I start the application and it tries to upgrade the database I get the following exception: …Caused by: […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.