---
title: "android中读取assets中的文件"
author: "dengzh"
date: "2011-06-28T09:42:11Z"
tags: ["Android", "文件", "读取Assets"]
categories: ["移动开发"]
slug: "android-assets"
draft: false
lastmod: "2011-07-12T18:36:39Z"
id: 1107277
url: "https://dengzh.iteye.com/blog/1107277"
---

```
   private Bitmap getImageFromAssetFile(String fileName){  
    Bitmap image = null;  
    try{  
        AssetManager am = context.getAssets();  
        InputStream is = am.open(fileName);  
        image = BitmapFactory.decodeStream(is);  
        is.close();  
    }catch(Exception e){  
          
    }  
    return image;  
}  
```

 

```
 InputStream in = getResources().getAssets().open(fileName);   
```