Ich mache ein Android-Projekt, wenn ich versuche, cursor.getCount() zu verwenden; es gibt mir eine Fehlermeldung:cursor.getCount() geben Fehler
cannot resolve symbol getCount();
Hier ist mein Code
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
{
}
definiere ich auch Cursor, ich verstehe nicht, warum es nicht funktioniert. Auch
,
ich versuchte if(cursor !=null)
es sagt mir
cursor unknown class
Anweisungen gehen in Methoden oder statische Blöcke. – njzk2
Ich denke, Ihr Code sollte Kompilierungsfehler haben. Könnten Sie den vollständigen Code "GetNotesFromDbTask" posten? – pooyan
Ich habe es gelöst. protected Boolean doInBackground (Void ... params) {return null;} schloss sich automatisch selbst, weil dieser Cursor nicht funktionierte. –