There are some extreme differences between these storage types. And it all depends on your use case which one you use.
SharedPreferences
is most likely a bad call here. Managing all those keys and being unable to iterate them in your preferences file is largely undesirable.
A hashtable only stores the data in memory, and will be lost whenever Android terminates the app or frees its memory. Additionally, this is a huge memory burden, dependent on what kind of data you're storing. (An int, int
map may not be so bad.)
Most likely the best way to do this is via SQLite in a background thread. As I said, it depends on your use case, but you will not be able to manage 30k keys without either a speed loss or excessive memory use. That's just the restriction on today's technology.