2 u014798453 u014798453 于 2014.08.04 13:40 提问

使用Cursor cursor=SQLiteDatabase.query()出现了空指针错误
enter code here`

package com.example.bluetooth.le;

import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.TextView;

public class zhuzhuang1 extends Activity {
public DBhelper helper = null;
public SQLiteDatabase db = null;
public Cursor cursor=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.zhuzhuang);
String TBL_NAME = "xiedian";
helper = new DBhelper(getBaseContext());
String strdata=Integer.toString(Calendar.getInstance().get(Calendar.YEAR))+
Integer.toString(Calendar.getInstance().get(Calendar.MONTH))+
Integer.toString(Calendar.getInstance().get(Calendar.DATE));

     cursor=db.query(TBL_NAME, new String[]{"bushu","karluli"}, "data=?", new String[]{strdata}, null,null, null);
     //cursor=db.query(TBL_NAME, null, null, null, null,null, null);
     if(cursor != null && cursor.getCount() >= 1)
     {   int i=cursor.getCount();
    TextView ceshi=(TextView)findViewById(R.id.ceshi);
    ceshi.setText(i+"");
     }
}

}

想了半天都不知道怎么改,还望各位大神赐教

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!