mardi 11 août 2015

Accessing row of SQLite Database

Im struggling with a bit of my code for my database, I have managed to access the id number of the item i click however i cannot access any more of the data? How can i do this?

For example now i have my id number i want to display all of that data on that row in a seperate window but i cant seem to pull the data with the cursor

String itemselect = String.valueOf(spinner.getSelectedItem());
Toast.makeText(Developer.this, itemselect, Toast.LENGTH_LONG).show();
final Cursor cursor = mydb.getAllRows(itemselect);
startManagingCursor(cursor);

String[] fromfieldnames = new String[]{
            DatabaseHelper.COL_1, DatabaseHelper.COL_2, DatabaseHelper.COL_3, 
            DatabaseHelper.COL_4, DatabaseHelper.COL_5, DatabaseHelper.COL_6 };
int[] toviewids = new int[]{R.id.textone, R.id.texttwo, R.id.textthree, R.id.textfour, R.id.textfive, R.id.textsix};
final SimpleCursorAdapter mycursoradapter = new SimpleCursorAdapter(this, R.layout.listtext, cursor, fromfieldnames, toviewids);
listView.setAdapter(mycursoradapter);

listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        Long string = mycursoradapter.getItemId(position);
        Toast.makeText(Developer.this, string.toString(),Toast.LENGTH_LONG).show();
        return true;
    }
});

There are no errors in this code I just need to try and add this extra functionality

Thanks in advance M.

Aucun commentaire:

Enregistrer un commentaire