How to reference a File in raw folder in Android

后端 未结 4 1205
陌清茗
陌清茗 2020-12-03 08:37

I just want to create a File object like this

File myImageFile = new File (\"image1\") ;

but it is giving me exception of FileNotFou

4条回答
  •  一向
    一向 (楼主)
    2020-12-03 09:13

    You can open it as InputStream, I don't know if possible as a file:

    int rid = resources.getIdentifier(packageName + ":raw/" + fileName, null, null);  
    //get the file as a stream  
    InputStrea is = resources.openRawResource(rid);  
    

提交回复
热议问题