I'm wanting to show an int value that I cast from a string in a Toast but it gives me an error that I do not understand.
When I perform these steps, the following error is thrown by the Logcat:
Process: com.example.rodrigo.libros, PID: 18227 android.content.res.Resources$NotFoundException: String resource ID #0x1
This is the part of the code where I am doing what I tell you:
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
BaseDeDatos admin = new BaseDeDatos(this);
SQLiteDatabase db = admin.getWritableDatabase();
Libros catego = null;
int cat;
listaLibros = new ArrayList<>();
cursor = db.rawQuery("select * from libros" , null);
while (cursor.moveToNext()){
catego = new Libros();
catego.setId(cursor.getString(0));
listaLibros.add(catego);
cat = Integer.parseInt(catego.getId());
Toast.makeText(getApplicationContext(), cat, Toast.LENGTH_SHORT).show();
}
That is, catego.getId () brings me the value "1" (String), so I use the variable cat to cast this value to int (1), but when I want to show its value in the Toast to verify that everything It goes well, I get that error mentioned above.
If you are wondering why I want to cast it to int, it is because I want to add a value to cat, (for example: cat + 3)
Thank you!