-1

I have a SQLite query:

private String showAllType = "select * from tbl_Type";

And I call it as shown below:

Cursor mCursor = mSQLiteDB.rawQuery(showAllType, null);

But when I check codestyle, it gives a warning: 'mCursor' hides a field' How can I fix this ?

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143

1 Answers1

0

The error message indicates, that you are using a local variable with the same name as a privously defined field. That is bad code design and should be avoided.

Rename your new Cursor variable to some other. mSomething is normally used for fields, not local variables.

Use cursor instead:

Cursor cursor = mSQLiteDB.rawQuery(showAllType, null);
// use 'cursor' for all the actions below
flx
  • 14,146
  • 11
  • 55
  • 70
  • Thank FLX so much. I see the problem ! Because I define a total varible : Cursor mCursor = null; so has that warning – user2760991 Sep 11 '13 at 06:57
  • hey @user2760991, if you want people answer your questions, you should accept them. this is the same for your other question. otherwise people will stop answering your. just press this arrow to make it green. – flx Sep 15 '13 at 03:55