I have recently started developing some app in Android Studio. I m trying to understand SQLite Database. I am trying to create a simple table n inserting into it. My application crashes after running the below code. Please help me.
SQLiteDatabase db = openOrCreateDatabase("StudentDB",android.content.Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS student "+ " (name VARCHAR, number VARCHAR );"); String name = ((EditText) findViewById(R.id.NameField)).getText().toString(); String num = ((EditText) findViewById(R.id.NumberField)).getText().toString();
db.execSQL("INSERT INTO student VALUES('"+name+"','"+num+"');");
Aucun commentaire:
Enregistrer un commentaire