안드로이드 개발 질문/답변
(글 수 45,052)
html을 폴더를 마우스로 끌어다가 assets폴더에 끌어놓는방법 말구요.
어플 실행하면서 특정파일(txt,html,etc..)생성해 assets폴더에 이파일을 넣으려고 합니다.
어렵네요 ㅠㅠ...
아래와 같이 하면 안되더라구요--;; assets폴더를 생성해주면서 파일을 넣어야 하는데 안되네요.
---------------------------------------------------------------------------------------
private void create_htmlfile() {
FileOutputStream fos;
try {
fos = new FileOutputStream("file:///android_asset/test.html");
fos.write("테스트용입니다".getBytes());
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}




File mkDir = getDir("폴더", Activity.MODE_PRIVATE);
String path = mkDir.getAbsolutePath();
File file = new File(path + "/파일명");
FileOutputStream fos = new FileOutputStream(file, false);
Writer out = new OutputStreamWriter(fos, "EUC-KR");
out.write(sb2.toString());
out.close();
이런 식으로 해보세용. 어셋 아래에 새로 폴더 만들고 (엄밀히 말하면 data/data/패키지 밑에...)
그 아래에 파일을 집어 넣는 방식입니다.