Should I use HashMap in Android project?

by Daniel » Sat, 28 Jun 2008 01:25:26 GMT


Sponsored Links
 Hi All,

I did not develop mobile project before, and now I must to develop an
Android project.

example, J2ME doesn't contain HashMap class.

I think it is under the consideration of performing.

I just want to know if I use some classes, which aren't included in
J2ME, can it have great influence on performin.

Thanks
Daniel

--~--~---------~--~----~------------~-------~--~----~



Should I use HashMap in Android project?

by Romain Guy » Sat, 28 Jun 2008 01:37:52 GMT


 Hi,

HashMap is a very useful class that performs well. Without knowing how
you intend to use this class, we cannot really tell you whether it
will impact performance or not. However, HashMap can be used without
any problem in a large number of situations without impacting
performance.

The only situation in which you might want to avoid HashMap is if you
need to store primitive types (int, long, short, etc.) inside, either
as key or value. This will force you to use autoboxing which will
create new objects (Integer, Long, Short, etc.). In such a situation,
you might want to use a SparseArray instead.






-- 
Romain Guy
www.curious-creature.org

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Wrong Position when using Big Images

Hallo,

i just stumpled over this:

In want to place an Image on the Bottom of the Screen, so i used an
RelativeLayout placed an ImageView in it:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
 android:layout_width="wrap_content"
android:layout_height="wrap_content" >

 <ImageView android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentBottom="true" android:src="@drawable/hand"
android:layout_gravity="bottom"/>
</RelativeLayout>

My Emulator ist API Version 8, with Screen Dimension 480x800. The
Image in the HDPI Folder was 652x652 in 240DPI. If i run it with this
Image (hand) i always get the Image Scaled but it shows up much more
over the Bottom as i would expect. The Image has NO transparent Border
that may would cause this.

When i scale the Image down to apx. width of the Screen (480x480) i
get a result i would expect.

Anybody can explain why Android Layout like this ?

PS: I did not put any other Images of that in the folders "mdpi" or
"ldpi" as alternatives !

best regards,
Jens




-- 

2. Ringtone playing just once.

Hello there,

I am working on a little Service that plays ringtones/alarm-tones and
such. What I want is to play a certain pattern with pauses and
therefore I need to play such a tone once. At the moment I tried
RingtoneManager/Ringtone and MediaPlayer. But both of them loop normal
ringtones. It is described in this issue
https://code.google.com/p/android/issues/detail?id=1320
that ogg files automatically loop if a certain tag in them is set.

What I also tried was to use SoundPool, but as I only have content://x/y
URIs to these ringtones and no real filepath as SoundPool needs, this
seems no choice either. Getting the filepath from the URI seems to be
no way either, as this seems to be just a part of the above URI and no
real filepath that points to a real file.
These URIs come from the RingtonePreference, so I have no other as
these.

So, how do I play a ringtone just once, if the location is specified
with a content-URI?

Cheers,
R.

-- 

3. Pinch Zoom on Image

4. Customizing a RelativeLayout

5. SQLite Implementation

6. HTC Evo Brand New feat HTC HD 2 and HTC touch Pro

7. [WTS] Nexian Journey New 990rb di i-gadget Bandung.