Failed to open Database in android app

前端 未结 2 1843
余生分开走
余生分开走 2021-01-22 09:58

in my app i am trying to fetch some data from database and i am showing it in a list. When i run the app in my Motorola(2.1) and in Samsung Ace(2.3) and i some of my emulators t

2条回答
  •  一生所求
    2021-01-22 10:16

    you try this code

    try {
            db = this.openOrCreateDatabase("chaek.db", MODE_PRIVATE, null);
            db.close();
            openDatabase();
            createTable();
        } catch (SQLException se) {
            Toast.makeText(this, se.getMessage(), 1).show();
        }
    private void openDatabase() {
        try {
    db = SQLiteDatabase.openDatabase("/data/data/com.pack.store/databases/chaek.db",
                    null, SQLiteDatabase.CREATE_IF_NECESSARY);
            //Toast.makeText(this, "DB was opened!", 1).show();
        } catch (SQLiteException e) {
            Toast.makeText(this, e.getMessage(), 1).show();
        }
    }// createDatabase
    

提交回复
热议问题