android getWriteableDatabase() 数据库报nullException。很可能是传入的context 为空。

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);

}



分析一下运行流程一下子就知道了。父类调用getData() ->   comlist =null(定义)   ->子类构造函数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值