欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android讀取Assets圖片資源保存到SD卡實例

 更新時間:2013年07月02日 15:01:12   作者:  
本文為大家詳細介紹下android讀取Assets圖片資源保存到SD卡的具體實現(xiàn),感興趣的各位可以參考下哈,希望對大家有所幫助
復制代碼 代碼如下:

public class ReadBitmap {
public void readByte(Context c, String name, int indexInt) {
byte[] b = null;
int[] intArrat = c.getResources().getIntArray(indexInt);
try {
AssetManager am = null;
am = c.getAssets();
InputStream is = am.open(name);
for (int i = 0; i < intArrat.length; i++) {
b = new byte[intArrat[i]];
// 讀取數(shù)據(jù)
is.read(b);
saveMyBitmap(Bytes2Bimap(b), MainActivity.DIR+name+i+".jpg");
}
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static Bitmap Bytes2Bimap(byte[] b) {
if (b.length != 0) {
return BitmapFactory.decodeByteArray(b, 0, b.length);
} else {
return null;
}
}

public static boolean saveMyBitmap(Bitmap bmp, String path) {
File f = new File(path);
try {
f.createNewFile();
FileOutputStream fOut = new FileOutputStream(f);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
fOut.flush();
fOut.close();
return true;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return false;
}
}

相關文章

  • 解決Android SELinux權限問題記錄分析

    解決Android SELinux權限問題記錄分析

    這篇文章主要為大家介紹了解決Android SELinux權限問題記錄分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-11-11
  • android中SharedPreferences實現(xiàn)存儲用戶名功能

    android中SharedPreferences實現(xiàn)存儲用戶名功能

    本篇文章主要介紹了android中SharedPreferences實現(xiàn)保存用戶名功能,詳細的介紹了SharedPreferences的功能,需要的朋友可以參考下
    2017-04-04
  • Android跨進程拋異常的原理的實現(xiàn)

    Android跨進程拋異常的原理的實現(xiàn)

    這篇文章主要介紹了Android跨進程拋異常的原理的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11
  • Kotlin中空判斷處理操作實例

    Kotlin中空判斷處理操作實例

    最近使用kotlin重構項目,遇到了一個小問題,在Java中,可能會遇到判斷某個對象是否為空,為空執(zhí)行一段邏輯,不為空執(zhí)行另外一段邏輯,下面這篇文章主要給大家介紹了關于Kotlin中空判斷處理操作的相關資料,需要的朋友可以參考下
    2022-07-07
  • Android 中Manifest.xml文件詳解

    Android 中Manifest.xml文件詳解

    這篇文章主要介紹了Android 中Manifest.xml文件詳解的相關資料,需要的朋友可以參考下
    2017-03-03
  • Flutter Reusable Lottie Animations技巧

    Flutter Reusable Lottie Animations技巧

    這篇文章主要為大家介紹了Flutter Reusable Lottie Animations技巧,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-12-12
  • Android中PopupWindow響應返回鍵并關閉的2種方法

    Android中PopupWindow響應返回鍵并關閉的2種方法

    這篇文章主要介紹了Android中PopupWindow響應返回鍵并關閉的2種方法,本文講解了最簡單的方法、最通用的方法,需要的朋友可以參考下
    2015-04-04
  • Android實現(xiàn)一鍵鎖屏功能

    Android實現(xiàn)一鍵鎖屏功能

    這篇文章主要介紹了Android實現(xiàn)一鍵鎖屏,在xml中創(chuàng)建device_admin.xml,在manifest中加入詳細文件,本文結合示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-10-10
  • Android實現(xiàn)雙向滑動特效的實例代碼

    Android實現(xiàn)雙向滑動特效的實例代碼

    這篇文章主要介紹了Android實現(xiàn)雙向滑動特效的實例代碼,具有很好的參考價值,希望對大家有所幫助,一起跟隨小編過來看看吧
    2018-05-05
  • android自定義按鈕示例(重寫imagebutton控件實現(xiàn)圖片按鈕)

    android自定義按鈕示例(重寫imagebutton控件實現(xiàn)圖片按鈕)

    由于項目這種類型的圖片按鈕比較多,所以重寫了ImageButton類,現(xiàn)在把代碼分享給大家,需要的朋友可以參考下
    2014-03-03

最新評論