Tag: sqlite

Android SQLite SQLiteOpenHelper IllegalStateException – DB Already Closed Error

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

What is the best way in Android to delete all rows from a table

I have a WCF witch provides some JSON data and then I save it into the local database. Works fine I have a Activity witch fills the data from a local database to a listview witch works fine. public void fillData() { // Fields from the database (projection) // Must include the _id column for […]

Sort a list in ascending order by date from sqlite

I am having a code for retrieving data like this. I wanted to get records with the dates in the ascending order.I tried using “KEY_DATE_TIME ASC” . but it didnt work. public Cursor fetchAllReminders() { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_PHONE,KEY_DATE_TIME}, null, null, null, null, null); }

Android sqlite rollback

I am doing database syn. Downloading data between sql server and sqlite.If there some circumstance while updating/inserting records in sqlite ,internet connectivity is slow or drop then need to roll back.Is it possible in this code or How to use Transaction here. public void insertTableRecords(String strTableName, String[] strToFields, String[] strValues){ DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(DownlaodTableActivity.this); dbAdapter.openDataBase(); […]

how to add WHERE clause to Query on android

I would like to limit the results to those whose KEY_HOMEID is equal to journalId. I’ve been on this for a couple days any help would be appreciated. public Cursor fetchAllNotes(String journalId) { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_HEIGHT, KEY_BODY, KEY_HOMEID},”FROM DATABASE_TABLE WHERE KEY_HOMEID = journalId”,null, null, null, null,null); }

How access existing sqlite database on Android Emulator?

So im new to working with databases in android, and I cant seem to figure out how to view a created database. I created the database adapter class and in my main activity class. I run it in the emulator with no issues, but how do I view the contents? The book im reading says […]

How implement one-to-many objects database in sqlite for android

I’m quite new to SQLite and SQL and I am struggling with how to approach the following: My app will display a list of community members. If I click a member, I can see a list of posts made by the members. A post is an object with name, time and message. How can I […]

How to find and clear the SQLite db file in Android (emulator)

I’ve just got my first SQLite database up and running but to reproduce it I wanted a quick way to clear the db file (so I can call my openOrCreateDatabase method again) First question: I see all over the web /data/data/PKG/databases/ but where exactly is this stored on a windows machine? It doesn’t appear to […]


I have to write a query in sqlite to update the record if it exists or insert it if the record do not already exists. I have looked the syntax of INSERT OR REPLACE INTO from here. But in my case, when I execute the query below many times the record is duplicated. i.e If […]

How do I pull the sqlite database from the android device?

How do I pull the sqlite database from the android device like emulator?

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