So guys i have got problem in my DbHelper class::
enter public class DbHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION =1;
public static final String DATABASE_NAME="skojarzenia";
public static final String DATABASE_TABLE="znane_wyrazy";
public DbHelper(Context context) {
super(context, DATABASE_NAME,null,DATABASE_VERSION);
SQLiteDatabase db = getWritableDatabase();
db.close();
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE "+DATABASE_TABLE+" (ENGLISH VARCHAR,POLISH VARCHAR)");
db.close();
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS"+DATABASE_TABLE);
onCreate(db);
db.close();
}
}
my class when i create object of this class:
public class Znasz extends AppCompatActivity {
DbHelper myDb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_znasz);
myDb = new DbHelper(this);
}
And when i create consturcotr "new Db..." then app "unexpected" closes
What is is wrong?? I supose something with query??
Please help :) Thanks
Aucun commentaire:
Enregistrer un commentaire