android - Large static map in program memory Java -
i translating 16-bit codes legacy device strings defined table. there on 2,000 codes, , codes not consecutive.
they defined in hashmap this...
public class someactivity { private static final map<integer, string> mymap; static { map<integer, string> amap = ...; amap.put(0x2345, "this"); amap.put(0xfea3, "that"); ... mymap = collections.unmodifiablemap(amap); } }
this being ported android, , concerned how ram use on device. can similar, stored in program memory?
a sparsearray
(http://developer.android.com/reference/android/util/sparsearray.html) more suitable basic hashmap.
you put in property file (see http://developer.android.com/reference/java/util/properties.html) put in assets of program (you still have load file in memory read 1 value)
you can pre-make sqlite database out of , copy assets (see http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/). in case, values in file, , required elements loaded.
however, wouldn't worry 2000 items in ram unless strings long.
Comments
Post a Comment