How to use session variables and sqlite in fragment

790 views Asked by At

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;
}  }
0

There are 0 answers