开发者

Open File on Sdcard

开发者 https://www.devze.com 2023-03-05 10:57 出处:网络
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?

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....

0

精彩评论

暂无评论...
验证码 换一张
取 消