Tag: sqlite

SQLiteOpenHelper.getWriteableDatabase() null pointer exception on Android

I’ve had fine luck using SQLite with straight, direct SQL in Android, but this is the first time I’m wrapping a DB in a ContentProvider. I keep getting a null pointer exception when calling getWritableDatabase() or getReadableDatabase(). Is this just a stupid mistake I’ve made with initializations in my code or is there a bigger […]

Android: SQLite one-to-many design

Anyone has good advise on how to implement one-to-many mapping for SQLite using ContentProvider? If you look at Uri ContentProvider#insert(Uri, ContentValues) you can see that it has ContentValues param that contains data to insert. The problem is that in its current implementation ContentValues does not support put(String, Object) method and class is final so I […]

Android: Accessing single database from multiple activities in application?

I have a todo list type application that stores all of the note data in a sqlite3 database. Each activity in the application needs access to the database to edit different parts of the data in real time. Currently, I have each activity open its own DBManager object (the helper class I created to manage […]

Sqlite Select Query with rawQuery at Android

I know it is a basic question, but i can not find problem. I try to get some columns with rawQuery. SQLiteDatabase db=database.getReadableDatabase(); try { String sql=”SELECT * FROM CAR WHERE name = “; Cursor crs = db.rawQuery(sql+”5P”, null); } I always get the same exception. android.database.sqlite.SQLiteException: **unrecognized token**: “5P”: , while compiling: SELECT * […]

SQLite – Is it possible to insert a BLOB via insert statement?

I’m developing an Android application and i’m using a Sqlite database to store some bitmaps. I want some images to be automatically inserted when the user installs the application. I’m using the SQLiteOpenHelper class like this: public class DatabaseHelper extends SQLiteOpenHelper { … DatabaseHelper(Context context, String nameOfDB, int version, String[] scriptSQLCreate, String scriptSQLDelete) { super(context, […]

Get SQLite database from Android app

I need get SQLite database from Android app from Genesis device where user has populated by hand. How I can create another app or any other way to get this db and save in place where I can get? obs.: the device has root Thanks

How can you access the contents of Android Emulator databases?

I’ve read the answer to a question as to how to access the contents of the databases, however I cannot seem to get it to work on my machine. Here is the shell log: C:\android-sdk-windows\tools>adb -s emulator-5554 shell # sqlite3 /data/data/com.android.demo.notepad2/databases/notes sqlite3 /data/data/com.android.demo.notepad2/databases/notes SQLite version 3.5.9 Enter “.help” for instructions sqlite> .tables .tables sqlite> ^C […]

What happens to a Sqlite database when app is removed

I’m new to Android programming and trying to wrap my head around this just to make myself clear about how things work. When creating Sqlite databases in an Android app, where is the database stored? Does it get deleted when the app is removed? Any info about this would be much helpful in understanding Android […]

Android SQLite Delete row issue

I am trying to delete a row from a table but i have three WHERE clauses and i am not sure if i am using the correct statement. db.delete(DBAdapter.TableName, “Id=”+ Id +” AND WHERE QstnrId = “+Integer.parseInt(QuestionnaireId) +” AND WHERE QstnId = “+Integer.parseInt(QuestionId), null); I am almost certain i am not using the statement correctly. […]

java.lang.IllegalStateException: attempt to re-open an already-closed object(Tried closing )

public int getRecordsCount() { String countQuery = “SELECT * FROM ” + TABLE_LOGIN; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(countQuery, null); if(cursor != null && !cursor.isClosed()){ cursor.close(); } // return count return cursor.getCount(); } I am trying to get the totalnumber of records in the database, but the database is getting crashed everytime with […]

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