But the exception is getting hit. How can I fix this? [edit]: I tried File f1=new File(Environment.getExternalStorageDirectory() + "//Prag.txt"); and f1 value = /mnt/sdcard/Prag.txt But still the exception gets hit. I have changed the permission too in manifest file [solution] As per Krishnabhadra's reply, I had to Make sure your SDCard is not mounted on a PC
SyncMaster asked Nov 18, 2011 at 10:52 SyncMaster SyncMaster 9,888 35 35 gold badges 102 102 silver badges 141 141 bronze badgesAndroid is based on linux so windows style paths like "J:\\prag.txt" won't work. In linux paths are like this: "/folder1/folder2/file.txt"
Also don't use hardcoded paths, because different phones might have different path for the SD card. Therefore you you should use Environment.getExternalStorageDirectory() that gives the path to the SD card programmatically.
File f1=new File(Environment.getExternalStorageDirectory() + "Prag.txt");
Also add necessary permission by:
Inside your manifest, somewhere outside application tag.