I have a listview in which i am adding the items whose values are retrieved from the table in my database. Now, in the current scenario, if i am deleting an item, i am passing the complete string and breaking it in parts to provide information to my delete query.
Instead of all these dumb work, i can simply pass the id of that particular item, but the id is not in the string array which is binded to the listview. How can i delete items from the database by simply using the item's id...?
Note: id is the column in table, so i have each item's id from database. But i am not displaying it in the listview.
String[] records = new String[report.size()];
for(int i = 0; i<report.size(); i++)
{
if(report.get(i).getDate()!="")
{
String eachRecord = (i+1) +". "+report.get(i).getDate() + " -- " + report.get(i).getType();
records[i] = eachRecord;
}
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.singlerow, records);
listView.setAdapter(adapter);