Tag: sqlite

How to migrate existing SQLite application to Room Persistance Library?

It might be a bit early to ask, but is it possible and how to migrate/upgrade an existing SQLite database application to a new Android Room Persistance Library?

Android: How to sum all the columns in a SQLite database and return 1 single variable

My objective is to sum all the columns in my database and return a variable ‘total’ = x amount. Example: column – food | taxi | clothes | sports 2 3 4 5 6 8 0 12 11 10 7 2 Then therefore the total will equate to = 70 My original idea was to […]

Android SQLite: Replace old database with a new one or use migration scripts

I have an Android app that uses a SQLite database and Active Android as ORM. On each app update I need to ship my database with new/updated data. This is what i’ve been doing I have a my_app.db database I make modifications on the rows, tables, etc. of the my_app.db I save the modified my_app.db […]

How to achieve the following in Realm for android

In my applications, I usually have a loader that loads the data from sqlite and then passes it on to either the activity or fragment it is attached, from where it is set in the adapter of a absListView which then presents it to the user Since realm states that its objects shouldn’t be shared […]

What does the SQLiteOpenHelper class do with the context parameter?

I am extending the SQLiteOpenHelper class. My constructor is public MyDatabaseHelper(Context context) { super( context, // ??? “MyDatabase.db”, // Database name null, // Cursor factory 1 // database version ); } What does the SQLiteOpenHelper constructor do with the context information? For my application, the constructor will behave the same regardless of the program state […]

Sqlite on Android: How to create a sqlite dist db function – to be used in the app for distance calculation using lat, long

We are building an Android App that will use user’s current location (lat, long) and show top 50 venues around the current location, sorted by distance. We have these venues stored in an SQLite DB. We plan to ship with the sqlite DB with the app. In order to fetch only the relevant top 50 […]

Where clause in SQLite not working in android :(

I’m getting an annoying error when trying to query some data in SQLite. Here is my code: Cursor cursor= db.query(TABLE_IMAGES, new String[]{“_id”}, “name” +” = “+compareToThis, null, null, null, null); I’m just returning the cursor as a string. The error is saying: no such column: compareToThis: while compiling…..the statement My question is: why is SQLite […]

how to store a time value in SQLite database in Android?

I want to store a timevalue in an SQLite database in Android. My time value is in EditText, and when I click the save button I would like the time value to be stored in the database. And also I want to review the already-stored value in the database.

Confused regarding SQLiteOpenHelper and creating multiple tables

I feel the Android developer guidelines regarding saving data in SQLite is really lacking. I’m confused as to what the general guideline is when it comes to multiple tables. I currently have two Managers that expose (CRUD) two different sets of entities to the UI. Do I: Create a private class SQLiteOpenHelper inside each Manager. […]

Android SQLite ORDER BY Doesn't Work

I have a very basic situation: I have a table with around 5k rows: CREATE TABLE “words” (“id” INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , “name” TEXT NOT NULL , “def” TEXT NOT NULL, “rand” INTEGER) Which I periodically update using “UPDATE words SET rand=random()” In android, when I create a cursor using rawQuery() using […]

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