How to get duration of an video file?
<p>I'm a beginner in Android programming.</p>

<p>I have been write an application to list all video file in a folder and display information of all videos in the folder. But when i try to get the video duration it return null and i can't find the way to get it.</p>

<p>Any one can help me?</p>

<p>Below is my code:</p>

<pre><code>Uri uri = Uri.parse("content://media/external/video/media/9");
Cursor cursor = MediaStore.Video.query(res, data.getData(), new String[]{MediaStore.Video.VideoColumns.DURATION});
if(cursor.moveToFirst()) {
    String duration = cursor.getString(0);
    System.out.println("Duration: " + duration);
}
</code></pre>
