private void hideKeyboard() {
    try {
        // Close Soft Keyboard
        InputMethodManager inputManager = (InputMethodManager)
                mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(rootView.getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception keyboardHideExp) {
        Log.d("eEmp/HideKbExp", "Exception raised due to " + keyboardHideExp.toString());
    }
}
This was used in fragment. I need to use same method in my class but giving error at rootView. How can I access in my class. 
inputManager.hideSoftInputFromWindow(rootView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
I am new to android.
Any help would be appreciated.
 
     
     
    