在之前的登录模块中userDao.find(name)这个方法是没有问题的。但是在这个方法中userDao.find(name)这个地方总是报错。
public class Information extends Fragment {
private TextView information_tv;
private MyApplication myApplication;
private UserDao userDao = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.information, null);
myApplication=(MyApplication) getActivity().getApplication();
information_tv=(TextView) view.findViewById(R.id.information_tv);
information_tv.setText(myApplication.getName());//这个地方也没有错误
String name=myApplication.getName();
Log.i(“MyApplication”, “Information+name值==” + name);//name有值
userDao.find(name);//在这个地方报错了 java.lang.NullPointerException
return view;
}
}