我遇到了无法在 Fragment 中加载 sqlite 数据的问题,如下所示
public class ListFragment extends Fragment {
DatabaseUtil dbUtil = new DatabaseUtil(this.getActivity());
private ArrayList <HashMap<String, Object>> getNews;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.activity_list, container, false);
new LoadNewsLists().execute("");
return v;
}
这是从 sqlite 加载数据
Cursor cursor = dbUtil.fetchAllData(arg[0]);
遇到以下错误。
03-08 12:21:52.900: E/AndroidRuntime(25895): Caused by: java.lang.NullPointerException
03-08 12:21:52.900: E/AndroidRuntime(25895): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)