Something is wrong with the cursor carrying data issue, debugging, i got that "java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed."
.
But i still can't adjust the cursor issue, i know that connection shouldn't be closed before cursor returning data, but i can't figure out how to adjust it.
I want to take some info from getEmpData method, and then pass it.
my method:
public Cursor getEmpData(Integer employeeID)
{
EmpDept = getReadableDatabase();
Integer[] empRow = {employeeID};
Cursor c = EmpDept.rawQuery("Select name, Title, phone, email from Employee where EmpID like ?", new String[]{employeeID.toString()});
if (c != null)
{
c.moveToFirst();
}
EmpDept.close();
return c;
}
List view part:
When name is clicked it should move the data to new activity.
namelist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
String name = namelist.getItemAtPosition(position).toString();
//Getting ID of emp,dept
Cursor empID = Emp.getEmpID(name);
Cursor DepID = Emp.getDeptID(name);
int eID = empID.getInt(0);
int dID = DepID.getInt(0);
Intent intent = new Intent(MainActivity.this, empDetails.class);
intent.putExtra("empName", Emp.getEmpData(eID).toString());
intent.putExtra("empTitle",Emp.getEmpData(eID).toString());
intent.putExtra("empPhone",Emp.getEmpData(eID).toString());
intent.putExtra("empEmail",Emp.getEmpData(eID).toString());
intent.putExtra("empDept",Emp.getDeptName(dID).toString());
startActivity(intent);
}
});