why setDataAndType() for an android intent works fine when setData() and setType() are not working?
<p>I had one issue with file editing in android using implicit intents, it got solved know, It took lot of time and permutations and combinations to solve it, but still finally I am left with doubt, The problem got solved but my quest to know why the problem got solved is not solved.</p>

<p>Please let me know if in case u have any clue on this.</p>

<p>Coming to my problem.</p>

<ol>
<li><p>I have an activity. I have a Button in the activity. I want to open a pre existing log file (which is a text file example log.txt) stored in the location "/mnt/sdcard/xxx/log.txt"</p></li>
<li><p>The below is the implicit intent code i wrote and i ended up with an exception " No activity found"</p></li>
</ol>

<p><strong>code1: which i tried and got exception</strong></p>

<pre><code>Uri uri = Uri.parse("file:///sdcard/xxx/log.txt");
Intent viewTestLogFileIntent = new Intent(Intent.ACTION_EDIT,uri);
viewTestLogFileIntent.setType("text/plain");
</code></pre>

<p><strong>code2: which i tried and got exception</strong></p>

<pre><code>Uri uri = Uri.parse("file:///sdcard/xxx/log.txt");
Intent viewTestLogFileIntent = new Intent(Intent.ACTION_EDIT);
viewTestLogFileIntent.setData(uri);
viewTestLogFileIntent.setType("text/plain");
</code></pre>

<p><strong>code3: which i tried and working fine</strong></p>

<pre><code>Uri uri = Uri.parse("file:///sdcard/xxx/log.txt");
Intent viewTestLogFileIntent = new Intent(Intent.ACTION_EDIT);
viewTestLogFileIntent.setDataAndType(uri,"text/plain");
</code></pre>

<p>Two doubts i have are</p>

<ol>
<li><p>First of all my file is located in /mnt/sdcard/xxx/log.txt this i can clearly see in the file system in DDMS view of eclipse, but how is it working when i give the file link in uri as "file:///sdcard/xxx/log.txt" where i skipped /mnt from path</p></li>
<li><p>what is wrong with code1 and code2?
what ever is the data and type i am setting in code3 i am setting same data and type on intent but with different methods like setData() and setType() seperately. why are they ( code2 &amp; code1) not working? why is the code3 working?</p></li>
</ol>
