title: Get duration of audio file Android
body: <p>I have a ListView with several audio files. For each one I have to get the duration in order to display it in the list.</p>
  
  <p>This is what I have tried yet:</p>
  
  <p><code>MediaPlayer getDuration()</code> -> takes about 1 sec for 13 items</p>
  
  <p><code>MediaStore</code> and <code>Cursor</code> -> takes about 2 sec for 13 items</p>
  
  <p>This is way too much for displaying the <code>ListView.</code></p>
  
  <p>So I have thought of this:</p>
  
  <p>creating a database with file-names and duration when recording the audio files</p>
  
  <p>-> this leads to a data inconsistency, because files could have been deleted</p>
  
  <p>Is there a alternative way to achieve this?</p>
  
  <p>Thanks in advance</p>