cursor.getCount();を使用しようとするとアンドロイドプロジェクトを作成しています。それは私にエラーを与える:cursor.getCount()エラーが発生しました
cannot resolve symbol getCount();
ここに私のコードは、私はそれが動作していない理由を私は理解していなかった、あまりにもカーソルを定義
class GetNotesFromDbTask extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... params) {
return null;
}
@Override
protected void onPreExecute() {
ProgressDialog dialog = new ProgressDialog(NoteDetail.this);
dialog.setTitle("Loading");
dialog.setMessage("Please wait..");
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.show();
}
SQLiteDatabase db = helpers.getReadableDatabase();
String[] projection = {
NoteContract.FeedEntry._ID,
NoteContract.FeedEntry.NOTES_TITLE,
NoteContract.FeedEntry.NOTES_ID,
NoteContract.FeedEntry.NOTES_BODY,
};
String sortOrder =
NoteContract.FeedEntry.NOTES_ID + " DESC";
Cursor cursor = db.query(
NoteContract.FeedEntry.TABLE_NAME, // The table to query
projection, // The columns to return
null, // The columns for the WHERE clause
null, // The values for the WHERE clause
null, // don't group the rows
null, // don't filter by row groups
sortOrder // The sort order
);
if(cursor.getCount()>0) //here i am getting error
{
}
です。
はまた、
は、私はそれはあなたのコードは、クラスの内部ではなく、クラスレベル自体にあるメソッド内でなければなりません
cursor unknown class
ステートメントは、メソッドまたはスタティックブロックに入ります。 – njzk2
私はあなたのコードはコンパイルエラーがあるはずだと思います。あなたは "GetNotesFromDbTask"クラスのフルコードを投稿できますか? – pooyan
私はそれを解決しました。 protected Boolean doInBackground(Void ... params){return null;}そのカーソルが機能しなかったため、自動的に閉じます。 –