How to open file with any exetension in Android?
<p>hello readers and helpers..!</p>

<p>(I m Newbie) </p>

<p><strong>Explanation:</strong> </p>

<p>I have 1 app in which user can upload file with any exetention(<strong><em>.png</em></strong>,<em><strong>.mp3</em></strong>,<em><strong>.txt</em></strong>,<em><strong>.pdf</em></strong>,<em><strong>.bmp</em></strong>,<em><strong>.apk</em></strong>,...etc)</p>

<p>In a nutshell-->** the file with any exe..!** </p>

<p>These files r displayed in list-view.</p>

<p>When user 'Tap' or 'click' on item from list-view intent will be called (<code>android.content.Intent.ACTION_VIEW</code>) and it should be open the respective application which installed in device.</p>

<p><strong>For Example</strong></p>

<p>If User Click on nature.png then intent will be called and suggest the applications like Gallery,PS Touch..etc(<strong>As shown in screen shot1</strong>)</p>

<p>If User Click on book.pdf then intent will be called and suggest the applications like MuPdf,Polaris Office,apv..etc(<strong>As shown in screen shot2</strong>)</p>

<p><strong>For .txt,.pdf,.png,.jpg</strong>-- I have solved the problem by set mime type <code>intent.setDataAndType(Uri.fromFile(file), mime);</code></p>

<p><strong>and</strong> also <strong>for URL</strong></p>

<pre><code>Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(https://www.google.co.in/));
</code></pre>

<p>It is working perfectly but for rest of the file extension i m still confused-
What to do? and how to do? </p>

<p>I have already dig around,but couldn't get satisfactorily answer..!</p>

<p><strong>My Questions:</strong></p>

<ol>
<li><strong>How can i write code for any file extensions so that it will call respective applications that installed in device??</strong></li>
<li><strong>How to define custom file extensions in XML?</strong></li>
</ol>
