0

I'm creating an android application which involves creating an Sqlite database, and opening when the application is ran again. While the application is running first time round, the database opens fine.

When it comes to running the app again and opening the database, I get a no such table error, though the tables were created when the application was running first time round. I also know the database exists and is being opened second time round (the onOpen() method is run and not the onCreate()).

I've taken the creating tables, populating etc out of the code below. I was wondering if I am missing something obvious?

The code Im using was from a tutorial I used ages ago:

public class DatabaseCreate {
private final static String DATABASE_NAME = "DBname";
private final static int DATABASE_VERSION = 1;
private DatabaseHelper mDbHelper;

Cursor mCursor;

SQLiteDatabase myDB;
Context mCtx;
static SQLiteDatabase db_Read = null;
private static class DatabaseHelper extends SQLiteOpenHelper {

    DatabaseHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);

    }

    @Override
    public void onOpen(SQLiteDatabase db) {


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {


    }

}

public DatabaseCreate (Context ctx) {

    this.mCtx = ctx;
}
public DatabaseCreate open(){

    mDbHelper = new DatabaseHelper(mCtx);
    myDB = mDbHelper.getWritableDatabase();
    return this;
}

Any help would be great, thanks.

1 Answer 1

1

See problem about sqlite database, no such table:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.