If I delete the line ” “number” + “text” “, the code works.
Error:
E/SQLiteLog: (1) table mytable has no column named number in “INSERT
INTO mytable(number,name,email) VALUES (?,?,?)”E/SQLiteDatabase: Error inserting number=866454 name=TEST email=TEST
android.database.sqlite.SQLiteException: table mytable has no column
named number (code 1 SQLITE_ERROR): , while compiling: INSERT INTO
mytable(number,name,email) VALUES (?,?,?)
String name = text_name.getText().toString();
String email = text_email.getText().toString();
String number = text_phone.getText().toString();
SQLiteDatabase data_base = dbHelper.getWritableDatabase();
ContentValues container = new ContentValues();
container.put("name", name);
container.put("email", email);
container.put("number", number);
long rowID = data_base.insert("mytable", null, container);
Log.d("Log: ", "row inserted, ID = " + rowID);
AND
@Override
public void onCreate(@NonNull SQLiteDatabase db) {
db.execSQL("create table mytable ("
+ "id" + "integer primary key autoincrement,"
+ "name" + "text,"
+ "email" + "text,"
+ "number" + "TEXT UNIQUE"
+ ");");
}