Working with SQLite in Android. Tools and stuff.

The Notepad tutorial uses sqlite to store the users entered notes. This is a single table, so this method query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) was fine.

It takes a single table name and some params for the other clauses. To use more than one table I used the rawQuery(String sql, String[] selectionArgs) method.

This takes arbitrary sql (union in my case) along with values to bind to any ? that you used.

I have removed the SQLiteOpenHelper from the code also. This opens and creates your database and handles upgrading the database following schema changes. Overall I found this cumbersome and have switched to moving the database file from the device (emulator) to my pc. I then query it using SQLite 2009 Pro. I got it here. Excellent query analyzer type tool. I make my changes here (schema and data) and then push this back to the device when I am ready to test with the app. The pushing is done with Eclipses DDMS perspective. If you work this way you don't need the SQLiteOpenHelper and can just run with a SQLiteDatabase instead. This is more straightforward.

Comments

Popular posts from this blog

Building a choropleth map for Irish agricultural data

Early Stopping with Keras

AutoCompleteTextView backed with data from SQLite in Android