android getWriteableDatabase() 数据库报nullException。很可能是传入的context 为空。
public class CommentListAdapter extends QBaseAdapter {
int size = 0;
List<CommentInfo> comlist = null;
boolean isShopContext ;
private String shopid;
public CommentListAdapter(Activity activity,
String shopid,boolean isShopContext) {
super(activity,shopid);
// TODO Auto-generated constructor stub
this.isShopContext = isShopContext;
this.shopid = shopid;
if(mData==null){
mData = new ArrayList<Map<String,Object>>();
}
System.out.println("comlist mData:"+mData);
System.out.println("comlist CommentListAdapter:"+comlist); //知道这一句会输出啥么?null
}
@Override
public List<Map<String, Object>> getData(Activity activity,String shopid) {
// TODO Auto-generated method stub
//DBOutHelper out = new DBOutHelper(activity);
//comlist = out.readCommentInfo(activity, shopid);
System.out.println("comlist:"+comlist);
Map<String, Object> map;
if (comlist == null)
comlist = new ArrayList<CommentInfo>()
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
this.mData = list;
return mData;
}
}
public abstract class QBaseAdapter extends BaseAdapter{
protected List<Map<String, Object>> mData;
protected LayoutInflater mInflater;
protected Activity activity;
public QBaseAdapter(Activity activity,String shopid){
this.mInflater =LayoutInflater.from(activity);
this.mData =getData(activity,shopid);
this.activity =activity;
}
public abstract List<Map<String, Object>> getData(Activity activity,String shopid);
}