Reputation: 436
I have an image in the res folder. I want it to be available in the File(java.io.File) object.
I am using:
File f = new File(new URI("drawable/small");
where small is the name of the image.
Upvotes: 4
Views: 2506
Reputation: 874
InputStream ins = getResources().openRawResource(R.drawable.icon);
BufferedReader br = new BufferedReader(new InputStreamReader(ins));
StringBuffer sb;
String line;
while((line = br.readLine()) != null){
sb.append(line);
}
File f = new File(sb.toString());
You can use openRawResource to copy a binary across from your raw resource folder to the device or in this case the File
Upvotes: 3
Reputation: 15089
Is it something like?
File f = new File(Uri.parse("android.resource://com.package.AppName/res/drawable/resource_name"));
Upvotes: -1