I'm trying below code in my fragment but when I debug application crash.
public class ChatFragment extends Fragment {
private TextView txtName;
private SQLiteHandler db;
private SessionManager session;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_chat, container, false);
// SqLite database handler
db = new SQLiteHandler(getActivity());
// session manager
session = new SessionManager(getActivity());
// Fetching user details from sqlite
HashMap<String, String> user = db.getUserDetails();
String name = user.get("name");
txtName = (TextView) getView().findViewById(R.id.textView);
txtName.setText(name);
return rootView;
} }