Good evening guys, I'm new here, I'm new to Android programming, but I decided to do my TCC, an Android project. by doing it alone, finding stuff on the internet, without taking Android classes, I'm going to do it well (or not), but I ran aground at a certain point.
I have a ListView that returns me the data from the SQLite database.
If I leave SELECT * FROM tbl_user; it brings me all the users registered in the database, but I just wanted to let the user who logged in to the system appear.
That is, I wanted to make a condition inside the Select, getting "SELECT * FROM tbl_user WHERE _id = id that is logged into the system."
But I can not, I've already lost two days looking for a way to do it, I've already changed the code structure and I'm lost.
Well, my code is there.
public class Area_Usuario extends ActionBarActivity{
private String TABLE;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.area_usuario);
TABLE = "tbl_usuario";
DatabaseHandler db = new DatabaseHandler(this);
Usuario usuario = new Usuario();
SQLiteDatabase db1 = db.getReadableDatabase();
String sql = ("SELECT * FROM " + TABLE);
Cursor cursor= db1.rawQuery(sql,new String[]{String.valueOf(usuario.get_id())});
String[] from = {"nome", "email", "senha"};
int[] to = {R.id.Usuario_RowNome, R.id.Usuario_RowEmail, R.id.Usuario_RowSenha};
ListView ltUsuario = (ListView) findViewById(R.id.listViewDadosUsuario);
SimpleCursorAdapter ad = new SimpleCursorAdapter(getBaseContext(), R.layout.usuario_row, cursor, from, to, 1);
ltUsuario.setAdapter(ad);
db1.close();
}
}