I am building an android library project which need some static resources(images/xml and etc) internally.
Then I wonder where I can put these resources and how to access them?
Since I put the resources in the assets
folder. And I use the AssetManager to access the resources:
AssetManager am = Resources.getSystem().getAssets();
InputStream is;
try {
is = am.open("t.jpg");
Drawable dw = Drawable.createFromStream(is, null);
Bitmap bm = ((BitmapDrawable) dw).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 100, stream);
} catch (IOException e) {
e.printStackTrace();
}
However I got the error: W/System.err(19583): java.io.FileNotFoundException: t.jpg
What is the problem?
.
stackoverflow.comm
No comments:
Post a Comment