karnage karnage - 3 months ago 34
Android Question

Android & Ormlite: Inserting data in DatabaseHelper onCreate

I am using Ormlite for the first time and I am trying to setup my DatabaseHelper to insert rows after creating the database's tables. I am getting a

getWritableDatabase called recursively
error when I do.

Here is my onCreate:

public void onCreate(SQLiteDatabase sqliteDatabase, ConnectionSource connectionSource) {

try {
TableUtils.createTable(databaseType, connectionSource, User.class);

// Add test user
User test = new User("test", "12345");

} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Unable to create databases", e);


The problem here was that @karnage was using an older version of ORMLite that had a bug with using the DAOs in the onCreate -- the pattern that he is using. This was fixed in version 4.6 (10/2010) and downloading and running the latest version works for him.

Here is the bug report:


Here's the change log file to track new features and versions of ORMLite: