Trying to convert String to JSONObject skips try & catch

If JsonObject throwing Exception. then your code will never executed the remaining try block.

Try this

private void retrieveState()
{
    try
    {
        JSONObject obj = new JSONObject(UserPreferences.getUserRegisterInfo());
        JSONObject row = obj.getJSONObject("UserRegistrationInfo");

    } 
    catch (Throwable t) 
    {
        t.printStackTrace();
    }
    finally
    {
        Toast.makeText(getContext(),"Your Message" ,Toast.LENGTH_SHORT).show();
    }
}

Leave a Comment