I am trying to make a decision on how to create my application.
I have about 300 class instances:
public class ParamValue { protected String sValue = null; protected short shValue = 0; protected short mode = PARAM_VALUE_MODE_UNKNOWN; }
I have an array of these instances. I canβt find out if these shorts really take 2 bytes or do they take 4 bytes?
And I need to pass the list of these objects through AIDL as List<Parcelable> . The premise cannot readShort() and writeShort() ; it can only work with int . So, to use short here too, I need to manually pack my two shorts into one int, send it, and then unpack it back. It looks too intrusive.
Could you tell me how many bytes it takes, and does it make sense to use short instead of int here?
UPDATE:
I updated my question for future readers.
So, I wrote a test application, and I realized that in my case there is no reason to use short , because it takes the same place as int . But if I define an array of shorts like this:
protected short[] myValues[2];
then it takes up less space than an array from ints:
protected int[] myValues[2];
android short
Dmitry Frank
source share