Open File on Sdcard
Hey, I want to open a .gif file on my sdcard. I used a temp .gif in the app and it works but开发者_如何转开发 I need to open the raw file on the sdcard and it is not letting me.... Can anyone help?
Code that works: http://pastebin.com/5kLvAG5c Code Im trying to use: http://pastebin.com/Q7t9QANQ
Thank you! :)
IIRC, openRawResource()
needs a resource id. It doesn't work with filepaths.
try replacing
is = context.getResources().openRawResource(location);
with
is = new BufferedInputStream( new FileInputStream(location) );
Remember, you'll need sdcard permissions.
Try this
String file = Environment.getExternalStorageDirectory()
.toString();
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/yourfilename.raw";
This will get your file in that string file. Then you proceed with your code....
精彩评论