Resources resources = getResources(); readLicenseFromRawResource(resources); ...
public void readLicenseFromRawResource(Resources resources) throws NotFoundException, IOException, FileNotFoundException { Copy2Phone(resources, R.raw.xxx, "xxx.jpg"); ... 중략 } public void Copy2Phone(Resources resources, int id, String path) throws IOException { byte [] buffer = new byte[8*1024]; int length = 0; InputStream is = resources.openRawResource(id); BufferedInputStream bis = new BufferedInputStream(is); FileOutputStream fos = new FileOutputStream("/sdcard/해당 경로명/"); while ((length = bis.read(buffer)) >= 0) fos.write(buffer, 0, length); fos.flush(); fos.close(); }
로그인 유지
해당 액티비티 클래스 안에서
public void readLicenseFromRawResource(Resources resources) throws NotFoundException, IOException, FileNotFoundException { Copy2Phone(resources, R.raw.xxx, "xxx.jpg"); ... 중략 } public void Copy2Phone(Resources resources, int id, String path) throws IOException { byte [] buffer = new byte[8*1024]; int length = 0; InputStream is = resources.openRawResource(id); BufferedInputStream bis = new BufferedInputStream(is); FileOutputStream fos = new FileOutputStream("/sdcard/해당 경로명/"); while ((length = bis.read(buffer)) >= 0) fos.write(buffer, 0, length); fos.flush(); fos.close(); }