안드로이드 외장 메모리(Download 폴더)에 파일 쓰기


WriteTextFile("FurInfo.txt", "Text Body.. 내용..");



    public boolean WriteTextFile(String strFileName, String strBuf) {

        try {

        File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

        File file = new File(path, strFileName);

            FileOutputStream fos = new FileOutputStream(file);

            Writer out = new OutputStreamWriter(fos, "UTF-8");

            out.write(strBuf);

            out.close();

        } catch (IOException e) {

            throw new RuntimeException(e);

        }

 

        return true;

    }


AndroidManifest.xml 에 권한 

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>



+ Recent posts