I am using ormlite.android.4.31.jar I have a typical DatabaseHelper
public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static final String DATABASE_NAME = "realestate.db"; private static final int DATABASE_VERSION = 1; private Dao<TabKraj, Integer> krajDao; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase sqliteDatabase, ConnectionSource connectionSource) { try { TableUtils.createTable(connectionSource, TabKraj.class); initData(); } catch (Exception e) { Log.e(DatabaseHelper.class.getName(), "Unable to create datbases", e); } } @Override public void onUpgrade(SQLiteDatabase sqliteDatabase, ConnectionSource connectionSource, int oldVer, int newVer) { try { TableUtils.dropTable(connectionSource, TabKraj.class, true); onCreate(sqliteDatabase, connectionSource); } catch (SQLException e) { Log.e(DatabaseHelper.class.getName(), "Unable to upgrade database from version " + oldVer + " to new " + newVer, e); } } public Dao<TabKraj, Integer> getKrajDao() throws SQLException{ if (krajDao == null) { krajDao = getDao(TabKraj.class); } return krajDao; } private void initData(){ Log.d(Constants.DEBUG_TAG, "data initiating"); TabKraj k1 = new TabKraj(); TabKraj k2 = new TabKraj(); k1.setNazov("Kosicky kraj"); k1.setId(1); try { getKrajDao().create(k1); } catch (SQLException e) { Log.e(Constants.DEBUG_TAG, "Data initialing ERROR"); } } }
the application is deleted, the data is cleared ... I run the application in debug mode from eclipse, the DatabaseHleper constructor is called, but onCreate() not called.
Where can the problem arise?
falconseye
source share