Hello friends I am new I have been following a video but at the moment of coloring the lines to show my database does not do anything.
- I HAVE ALREADY BEEN ABLE TO ADD SUCCESSFULLY
- THE METHOD DOES NOT WORK showClassroom DevelopersBD
- WHICH IS INSTANCED IN THE MainActivity CLASS TO SHOW IN THE LIST
could advise me with the code attached to the code where I think the error is because to insert use CONTENTVALUES AND TO SHOW I'M USING SQLiteDatabase AT THE END ANNEX MY CODE GITHUB AND THE TWO VIDEOS THAT YOU USE
public void insert_artista(String n_cancion, String n_artista, String genero, String letra, String nota){
ContentValues contentValues = new ContentValues();
contentValues.put("NAME_CANCION", n_cancion);
contentValues.put("NAME_ARTISTA", n_artista);
contentValues.put("NAME_GERO",genero);
contentValues.put("NAME_LETRA",letra);
contentValues.put("NAME_NOTA",nota);
this.getWritableDatabase().insertOrThrow("ARTISTA","",contentValues);}
public List<CantanteDatos> mostrarArtistas(){
SQLiteDatabase bd=getReadableDatabase();
Cursor cursor = bd.rawQuery("SELECT * FROM ARTISTA",null);
List<CantanteDatos> cursos = new ArrayList<>();
if (cursor.moveToNext()){
do {
cursos.add(new CantanteDatos(cursor.getString(0),cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4)));
}while (cursor.moveToNext());
}
return cursos;
}