Search code examples
androidandroid-lint

How to suppress "UseSparseArrays" for a statement?


Some lints can be suppressed for a statement. E. g., "division by zero" lint:

//noinspection divzero
int i = 3 / 0;

But some lints can't be suppressed for a statement in the same way. E. g.:

//noinspection UseSparseArrays   <-- Has no effect
Map<Integer, String> map = new HashMap<>();

What is the difference between these two lints? Can we suppress lints like "UseSparseArrays" for a statement in some other way? (Don't want to suppress it for the whole method).


Solution

  • What is the difference between these two lints?

    After some research, I found an answer:

    Can we suppress lints like "UseSparseArrays" for a statement in some other way?

    According to Android documentation Android lint warnings can be suppressed only for a class or a method with @SuppressLint.