Tag: sqlite

SQLite rawQuery selectionArgs and Integers Fields

As the Android documents says, the selectionArgs parameters of the rawQuery method is parsed as strings. SQLiteDatabase.rawQuery(String sql, String[] selectionArgs) selectionArgs: You may include ?s in where clause in the query, which will be replaced by the values from selectionArgs. The values will be bound as Strings. But today, I was faced with a problem […]

Indentifying datatype of a column in an SQLite Android Cursor

Is there any way to identify the datatype of a column in a cursor in Android. The cursor object has a number of methods to get the columnname, column value. I want to find out the SQLite datatype of the column (TEXT, INTEGER) etc… I’m writing a generic function to parse a cursor and perform […]

Select at least one from each category?

SQLFiddle Link I’ve got an SQLite database with a bunch of test/exam questions. Each question belongs to one question category. My table looks like this: The goal What I’m trying to do is select 5 random questions, but the result must contain at least one from each category. The goal is to select a random […]

Updating sqlite database versions?

I have a database that I want to add a column to, I changed the static database version but when I run the program on my device the new column is still not there so I am guessing my onUpdate is not getting called and I am not sure why. this is how I create […]

Android: SQLite – insertWithOnConflict

I am calling insertWithOnConflict, using SQLiteDatabase.CONFLICT_IGNORE. However, when a conflict occurs “-1” is returned instead of the id of the existing row. How do I correct this? Table creation: EDIT : String CREATE_CATEGORY_TABLE = “CREATE TABLE “+TABLE_CATEGORY+”(” + BaseColumns._ID+” INTEGER PRIMARY KEY AUTOINCREMENT, “+ KEY_CATEGORY_NAME+” TEXT UNIQUE” + “)”; db.execSQL(CREATE_CATEGORY_TABLE); Insert statement: ContentValues values = […]

inspecting android sqlite and IntelliJ

I’m starting out with a small app using programmatically created sqlite db. Is there a way to inspect that db when the app is running on emulator?

Android OrmLite pre-populate database

Is it possible with OrmLite to create a sql script file to easily populate the database with data? I did some searching and couldn’t come up with anything easy. I know I can create some objects with data, I’m just looking for a cleaner method. I’m thinking create a script file, open a a reader […]

Maximum number of rows in a sqlite table?

Is there some limit of rows for a sql lite table ? My app is giving a error ” no such table x…” when that table have more than 6000 rows. Below the 6000 rows, dont give any error. Thank you. This is the query. db = (new DatabaseHelper(this)).getWritableDatabase(); cursor = db.rawQuery(“SELECT continentes._id, continentes.ContinenteID, continentes.Continente” […]

SQLite Android . unable to open database file

I found a lot of question about this problem, but i can’t fix it. I have a sqlite db in assets folder: assets/data/data/{package_name}/databases/mydb.db I can open database and read data before change one table structure. I try to uninstall the app and reinstall again, but i get the same exception. What can i do now? […]

How to use SQLite DB from AsyncTask?

I’ve been using my Activity class to access my DB which made my program freeze sometimes. So I decided to use AsyncTask instead to handle the DB. My problem is I don’t know how to instantiate my SQLite DB “TheDB” from AsyncTask’s class public class myClass extends AsyncTask<Void, Void, Void>{ private TheDB db; any method() […]

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