-2

Am getting an error saying resource id can't be found tried tracing the problem the code seems fine

This area contains my class that uses the xml resource below to show all the necessary elements anyone who can help to tell me why am getting such an error

    @Bind(R.id.showfirstname)
    MyEditText Myfirstname;

    @Bind(R.id.showlastname)
    MyEditText Mylastname;

    @Bind(R.id.showEmail)
    MyEditText Myemail;

    @Bind(R.id.profilephone)
    MyEditText Mytel;



private  Source mDataSource = new Source(this);

    Cursor userDataCursor;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_profile);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);


        ButterKnife.bind(this);

        mDataSource.open();

        userDataCursor = mDataSource.selectUserData();
        userDataCursor.moveToFirst();


        Myfirstname.setText(userDataCursor.getColumnIndex("firstname"));
        Myfirstname.setEnabled(false);
        Mylastname.setText(userDataCursor.getColumnIndex("lastname"));
      Mylastname.setEnabled(false);
       Myemail.setText(userDataCursor.getColumnIndex("email"));
    Myemail.setEnabled(false);
     Mytel.setText(userDataCursor.getColumnIndex("tel"));
     Mytel.setEnabled(false);




        mDataSource.close();

    }
  • I guess data is null, Check *userDataCursor* is null are not, print log *userDataCursor.getColumnIndex("firstname")* then you can able to trace problem ease. – Srihari Nov 23 '16 at 12:46

1 Answers1

0

The getColumnIndex method won't give you the value of that column. It only gives you the index of that column in your database.

You should do it like this:

userDataCursor.getString(userDataCursor.getColumnIndex("firstname"));

Mohammad Zarei
  • 1,773
  • 14
  • 33