title: Android Performance: Strings vs. Enums vs. Static Final Ints
body: <p><em>Parts of this have been asked on SO before, but I'm yet to find much in the way of solid evidence and/or a decisive answer.</em></p>
  
  <p>When passing information around Android in a Bundle, what (if any) performance increases/decreases can be observed by using <strong>strings</strong>, <strong>enums</strong> or <strong>static final ints</strong>?</p>
  
  <p>To give an example use case, there are several times in my app where a certain fragment is loaded and displayed. Each time the fragment is loaded, a Bundle is passed to it containing two arguments: an ID of the data is is showing, and a mode to dictate how to show it. I have a custom state pager adapter set up doing all the heaving lifting, but the crux of the question is here: which (if any) of these would offer any performance gains/losses:</p>
  
  <pre><code>Bundle args = new Bundle();
  args.putInt("ID", 1);
  
  // method 1
  args.putString("MODE", "Mode1");
  
  // method 2
  args.putSerializable("MODE", ModeEnum.Mode1);
  
  // method 3
  public static final int MODE_1 = 1; // this would be elsewhere in a constants class
  args.putInt("MODE", MODE_1);
  </code></pre>
  
  <p>In the fragment, the mode is checked in several places, so I'm concerned with which of the three options is more efficient to store in the bundle, and which is more efficient to be compared on the other end.</p>
  
  <p>Any advice, observations or experiences will be greatly appreciated!</p>