Database Connection not established in Android
<p>I ama trying to write this code for connection in Android.</p>

<pre><code>public class DataBaseAdapter
{
....
....
    public DataBaseAdapter(Context context)
    {
        contextApp = context;
        myAlarmDB = new MyAlarmDatabase(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
    public DataBaseAdapter open() throws SQLException 
    {
        try
        {
            db = myAlarmDB.getWritableDatabase();
        }
        catch (SQLiteException ex)
        {
            db = myAlarmDB.getReadableDatabase();
        }
        return this;
    }
}
</code></pre>

<p>When any code calls <code>open()</code> method the Android App Terminates with error.
and when this particular code is commented then the application runs. That is it creates SQLiteDatabase objects freely.</p>

<p>Please help me what should I do.?</p>

<p>This is code for the class which connects to <code>SQLiteOpenHelper</code></p>

<pre><code>public class MyAlarmDatabase extends SQLiteOpenHelper
{   
    private static final String CREATE_STATEEMENT=
    "create table if not exists AlarmDataBase" +
    "(alarm_id integer primary key auto_increment," +
    " description text," +
    " repeatType integer," +
    " repeatDay text," +
    " millis text)";
    public MyAlarmDatabase(Context context, String name, CursorFactory factory, int version)
    {
            super(context, name, factory, version);
            // TODO Auto-generated constructor stub
    }
    @Override
    public void onCreate(SQLiteDatabase db)
    {
        //db = SQLiteDatabase.openOrCreateDatabase("AlarmManagerDatabase.db", Context.MODE_PRIVATE, null);
        db.execSQL(CREATE_STATEEMENT);
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        // TODO Auto-generated method stub
        Log.w("TaskDBAdapter", "Upgrading from version " + oldVersion + " to " + newVersion + ", which will destroy all old data");
        // The simplest case is to drop the old table and create a new one.
        db.execSQL("create table alarm_standby as select * from AlarmDataBase");
        db.execSQL("DROP TABLE IF EXISTS AlarmDataBase");
        db.execSQL("create table AlarmDataBase as select * from alarm_standby");
        db.execSQL("drop table alarm_standby");
    }
}
</code></pre>
