Mobile/Android
[Android]Asset 폴더 접근
out of coding
2015. 1. 21. 11:46
Asset폴더에 파일을 저장하였다가 가져와서 사용할 경우가 있다.
예를 든다면, 웹페이지를 넣어서 파일을 불러와서 할 경우도 있을 것이며,
특정 이미지를 불러와서 화면에 보여주거나, 음악파일을 불러와서 사용한다던지.
이용약관을 파일로 저장하고 있다가 텍스트를 가져와서 사용한다던지.
이용범위가 넓긴하다.
사용방법.
1. Asset Folder에 WebPage를 넣어두고 가져올 경우
webView.loadUrl("file:///android_asset/index.html");
2. AssetManager를 이용하는 방법
AssetManager assetmanager = getResources().getAssets(); Bitmap bitmap = null; try { InputStream is = assetmanager.open("폴더/파일", AssetManager.ACCESS_BUFFER); bitmap = BitmapFactory.decodeStream(is); } catch(Exception e) { }