嘿家伙,即时通讯工作在一个简单的测验和即时消失的疯狂! 问题是,一切工作(数据库创建,因为它应该),除非我试图从数据库中获取字符串显示java.lang.NullPointerException.I检查uri更正和数组中的项目数!!我试图找出为什么这会发生5个小时,我被困在这里!!!我不知道该做什么事情!!你的帮助不仅仅是赞赏!Android的定制内容提供商
在这里我想获得字符串我的主类是一个大胆
Uri newUri = ContentUris.withAppendedId(
QuestionsProvider.CONTENT_URI,
this.currentQuestion);
Log.d(TAG, "SHOWQUESTION " + " URI="+newUri.toString());
Cursor cursor = cr.query(newUri,
null, null, null, null);
if (cursor.moveToFirst()) {
**question.setText(cursor.getString(
QuestionsProvider.QUESTION_COLUMN)); //HERE I AM GETTING THE ERROR
currentAnswer = cursor.getString(
QuestionsProvider.ANSWER_COLUMN);**
submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String text;
String answerGiven =
answer.getText().toString();
answer.setText("");
if (answerGiven.
equalsIgnoreCase(currentAnswer))
{text = "Correct";
}else{
text = "Wrong - "+currentAnswer;
Toast.makeText(getApplicationContext(),
text, Toast.LENGTH_SHORT).show();
}
}});
}
cursor.close();
dialog.show();
,并在我的清单我成功地添加提供程序和加载,因为它应该! 为什么会发生这种错误?我可以看到任何错误!
列不应该硬编码(在我看来)。你能发布错误信息吗? – alibi 2011-03-31 21:54:34