0

I want to create a class and it extends the SparseArray. The mKeys and mValues are private in SparseArray , so it cannot be accessed in my Class. But I need do some special things about the mKeys and mValues. How to handle it ?

http://developer.android.com/reference/android/util/SparseArray.html

Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71
  • I don't know android, but generally this time (if you have to do something special) you might be better of applying the composition over inheritance principle, although I don't know your usecase – maczikasz Jun 03 '14 at 08:58
  • 1
    Could you provide more info about what you’re trying to achieve? Generally, there is no way to access a private member unless you use reflection, which I would’t recommend. – Tadej Jun 03 '14 at 09:17
  • @curtisLoew Just want to accessed the private member. Can you explain the reflection way ? By the way, I want to say that the case just for study.Thanks. – Jerikc XIONG Jun 03 '14 at 10:06

1 Answers1

0

Well if mkey and mvalue are private and there is no geter and seter I don't think there is a way to access them in normal way without hacking code coz private modifier was designed to do not let developer access them

NoXSaeeD
  • 924
  • 1
  • 7
  • 13