개발/개발 자료

[Android] assets 접근하여 파일 가져오기

시원한물냉 2013. 9. 10. 13:45


AssetManager assetmanager = getResources().getAssets();

Bitmap bitmap = null

try{

           InputStream is = assetmanager.open("폴더/파일",AssetManager.ACCESS_BUFFER);

           bitmap = BitmapFactory.decodeStream(is);

}catch(Exception e){

}



만약  Layout과 같이 Id값으로  배경을 주지 못한다면,

Drawable drawable = (Drawable)(new BitmapDrawable(bitmap));

으로 형변환 해서 setBackground drawable주면 된다.