title: How to print a double with two decimals in Android?
body: <p>Maybe this is a silly question, but I cannot guess how to solve it if it's not creating a method. Maybe there's a "natural way" to do it, like in C for example. Here's the problem:</p>
  
  <p>I have a var:</p>
  
  <pre><code>double a;
  </code></pre>
  
  <p>And I want to show it only with 2 or 3 decimals. When I try to show it:</p>
  
  <pre><code>Text.setText("Value of a: " + String.valueOf(a));
  </code></pre>
  
  <p>It gives something like:</p>
  
  <blockquote>
    <p>Value of a: 5.234966145</p>
  </blockquote>
  
  <p>And i would want just</p>
  
  <blockquote>
    <p>Value of a: 5.23</p>
  </blockquote>
  
  <p>Without changing the real value of a so it shows the approximate number but works with the real number.</p>