SQLite INSERT AND MOST in ListView and CardView

0

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;
    }
  

link
link
link

ANDROID STUDIO PROJECT

    
asked by Austin Arenas 11.10.2018 в 23:23
source

1 answer

0

In the Adapter you are returning null instead of a view (viewHolder). Fixed like this:

 public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.itme_nota,viewGroup,false);
    ViewHolder viewHolder = new ViewHolder(view);
    return viewHolder;
   }
    
answered by 12.10.2018 в 02:50