安卓程序raw文件放在sd卡代碼實例
來源:易賢網 閱讀:883 次 日期:2014-08-21 16:08:14
溫馨提示:易賢網小編為您整理了“安卓程序raw文件放在sd卡代碼實例”,方便廣大網友查閱!

void copyAssets()

{

String[] files;

try

{

files = this.getResources().getAssets().list("");

}

catch (IOException e1)

{

return;

}

if(!mWorkingPath.exists())

{

if(!mWorkingPath.mkdirs())

{

new AlertDialog.Builder(this)

.setTitle(R.string.ERROR)

.setMessage(R.string.FAILED_DIR_CREATE)

.setPositiveButton(android.R.string.ok, new OnClickListener(){

@Override

public void onClick(DialogInterface dialog, int which)

{

dialog.dismiss();

}

})

.create()

.show();

}

}

for(int i = 0; i < files.length; i++)

{

try

{

String fileName = files[i];

if(fileName.compareTo("images") == 0 ||

fileName.compareTo("sounds") == 0 ||

fileName.compareTo("webkit") == 0)

{

continue;

}

File outFile = new File(mWorkingPath, fileName);

if(outFile.exists()) continue;

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

OutputStream out = new FileOutputStream(outFile);

// Transfer bytes from in to out

byte[] buf = new byte[1024];

int len;

while ((len = in.read(buf)) > 0)

{

out.write(buf, 0, len);

}

in.close();

out.close();

}

catch (FileNotFoundException e)

{

e.printStackTrace();

}

catch (IOException e)

{

e.printStackTrace();

}

}

更多信息請查看IT技術專欄

更多信息請查看網絡編程
易賢網手機網站地址:安卓程序raw文件放在sd卡代碼實例

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯(lián)系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網