0
I’m a beginner in android development and I’m trying to create a table in sqlite where the value of email will be unique. Only the app is allowing you to register equal emails.
@Override
public void onCreate(SQLiteDatabase db) {
try {
String sql = "CREATE TABLE usuario (" +
"id INTEGER PRIMARY KEY NOT NULL," +
"email TEXT NOT NULL UNIQUE," +
"senha TEXT NOT NULL);";
db.execSQL(sql);
Toast.makeText(UsuarioRepository.this.contexto, "Tabela criada com sucesso", Toast.LENGTH_LONG).show();
}catch (SQLException ex){
Toast.makeText(UsuarioRepository.this.contexto, "Erro ao criar tabela: "+ex, Toast.LENGTH_LONG).show();
}
}
If your application allows registering equal emails but your table does not allow then the error must be in your application. Another thing that may be occurring is that some space character at the beginning or end of the email may be differentiating seemingly equal emails. Remove any unnecessary spaces.
– anonimo