res文件夹下的文件都是参与编译的,通过id可以查找到
assets文件夹下的资源不参与编译.
下面是assert中文本的读取方式
try {
InputStream in = getAssets().open("data");
byte[] bytes = new byte[in.available()];
in.read(bytes);
String str = new String(bytes,"utf-8");
System.out.println(str);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assets中图片的
ImageView iv = (ImageView) findViewById(R.id.iv);
try {
InputStream in = getAssets().open("1.png");
Bitmap bm = BitmapFactory.decodeStream(in);
iv.setImageBitmap(bm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}