我收到 NullPointerException: println 尝试启动活动时需要消息错误。我看不到错误。
这是我关于错误的数据库
public HashMap<String, String> getsaleInfo(String saleId) {
HashMap<String, String> wordList = new HashMap<String, String>();
SQLiteDatabase database = this.getReadableDatabase();
String selectQuery = "SELECT * FROM SUPERSALE where supersaleId='"+saleId+"'";
Cursor cursor = database.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
//HashMap<String, String> map = new HashMap<String, String>();
wordList.put("saleCust", cursor.getString(1));
wordList.put("saleName", cursor.getString(2));
wordList.put("saleTime", cursor.getString(4));
wordList.put("saleTax", cursor.getString(5));
wordList.put("saleNotes", cursor.getString(6));
//wordList.add(map);
} while (cursor.moveToNext());
}
return wordList;
}
这是我在活动中检索的方式
saleCust = (TextView) findViewById(R.id.saleCust);
saleNotes = (TextView) findViewById(R.id.saleNotes);
saleName = (TextView) findViewById(R.id.saleName);
saleTime = (TextView) findViewById(R.id.saleTime);
saleTax = (TextView) findViewById(R.id.saleTax);
Intent objIntent = getIntent();
String saleId = objIntent.getStringExtra("supersaleId");
Log.d("Reading: ", "Reading all contacts..");
HashMap<String, String> saleList = controller.getsaleInfo(saleId);
Log.d("saleCust",saleList.get("saleCust"));
Log.d("saleName",saleList.get("saleName"));
Log.d("saleTime",saleList.get("saleTime"));
Log.d("saleTax",saleList.get("saleTax"));
Log.d("saleNotes",saleList.get("saleNotes"));
if(saleList.size()!=0) {
saleCust.setText(saleList.get("saleCust"));
saleName.setText(saleList.get("saleName"));
saleTime.setText(saleList.get("saleTime"));
saleTax.setText(saleList.get("saleTax"));
saleNotes.setText(saleList.get("saleNotes"));
}}
错误来自线路
Log.d("saleCust",saleList.get("saleCust"));