我有一个 MunchaDbAdapter,它打开连接并将 SQLiteDatabase 初始化为 getWritableDatabase,如下所示:
public MunchaDbAdapter open() throws SQLException {
mDbHelper = new MunchDbHelper(mCtx);
mDb = mDbHelper.getWritableDatabase();
return this;
}
现在在另一个班级我像这样打开了 MunchaDbAdapter
private MunchaDbAdapter mDbHelper;
private SQLiteDatabase mDb;
public long insert(Recipient recipient, String[] images){
ContentValues initialValues = new ContentValues();
initialValues.put(FLD_RECIPIENT_ID, Recipient.getFldRecipientId());
initialValues.put(FLD_INFO, Recipient.getFldInfo());
initialValues.put(FLD_LATITUDE, Recipient.getFldLatitude());
initialValues.put(FLD_LONGITUDE, Recipient.getFldLongitude());
for(int i=0;i<images.length;i++){
if(images[i]!=null){
initialValues.put("FLD_IMAGE_URL"+(i+1), images[i]);
}
}
mDbHelper.open();
return mDb.insert(DATABASE_TABLE, null, initialValues);
}
这是我的错误,mDb 为空,那么任何机构都可以提到它有什么问题?