I'm trying to read data from newly deleted SQLite db table row.
Basically my program will delete a row when a certain activity is loaded, and I want to check the value inside the row.
This is my get
code :
public String getSlot() {
String slots = new String();
Cursor cursor = database.query(ChosenSlotDatabaseHandler.TABLE_CHOSEN_PARKING_SLOT,
chosenSlotColumn, null, null, null, null, null);
if( cursor.moveToFirst() ) {
slots = cursor.getString(0);
}
// make sure to close the cursor
cursor.close();
return slots;
}
I've used these codes to delete the value :
public static final String DELETE_SLOT = "DELETE FROM "
+ TABLE_CHOSEN_PARKING_SLOT + " WHERE "
+ "_ID = " + CHOSEN_ID + ";";
public void deleteSlotSQL()
{
database.execSQL(ChosenSlotDatabaseHandler.DELETE_SLOT);
}
And this is my condition to set a TextView
value :
if(slots == null)
{
chosenSlotView.setText("You have not parked");
}
else
{
chosenSlotView.setText("You are parked in : " + slots);
}
At first, I thought that once the only row is deleted, getSlot()
would return null, but it seems that it's not null from this Log.d
I ran :
if(slots != null)
{
Log.d("notnull","not null dude");
}else
{
Log.d("null","Yay null");
}
The log
returns "not null dude"..
Any suggestion on how to get the slots
value so I can set the TextView
value??
your
slots
definitely not null because of this : String slots = new String();it should be
EDIT :
Nevermind that
String slot = null
,Try using :