Reputation: 17257
I'm trying to access the image on the SD card using below code but I"m getting File not found exception. Can someone tell me a correct way to acess the file???
new File("/mnt/sdcard/splah2.jpg")
Upvotes: 3
Views: 12584
Reputation: 9
try
new File("/sdcard/splah2.jpg")
or
new File(Environment.getExternalStorageDirectory() + "/" + "splah2.jpg")
both are same if SD card is install because,
Environment.getExternalStorageDirectory() returns "/sdcard"
Upvotes: 0
Reputation: 2218
The code below has worked for me.
String mRelativeFolderPath = "/DCIM/Camera/"; // i.e. SDCard/DCIM/Camera
String mBaseFolderPath = Environment.getExternalStorageDirectory().getAbsolutePath() + mRelativeFolderPath;
String filePath = mBaseFolderPath + "test.jpg";
File handle = new File(filePath);
Shash
Upvotes: 0
Reputation: 3021
Try like this:
String SD_CARD_PATH = Environment.getExternalStorageDirectory().toString();
new File(SD_CARD_PATH + "/" + "splah2.jpg");
Upvotes: 8
Reputation: 3527
Try running: new File(Environment.getExternalStorageDirectory() + "/splah2.jpg")
Upvotes: 3