Unlocking Android에 나와 있는 코드를 이용하여 아래와 같이 만들어 사용하였다..
코드가 길지 않기 때문에 주석은 생략...

----- 변수 선언 ------
    private final String mPath = "/mnt/sdcard";    //SD카드 기본경로
    private final String mNewFolder = "test_folder";    //폴더이름
    private File mFile = null;
    private String mFilePath = null;
    private byte[] mTestFile = "1234".getBytes();
    private static String mFileName = System.currentTimeMillis() + ".txt";
----- 변수 선언 ------

1. 파일 생성
private boolean createFileFolder()
    {
        File fileDir = new File( mPath );
        try
        {
            if( fileDir.exists() && fileDir.canWrite() )
            {
                mFilePath = fileDir.getAbsolutePath() + "/" + mNewFolder;
                Log.e( "getAbsolutePath()", "getAbsolutePath() = "  + fileDir.getAbsolutePath() );
                File newFolder = new File( mFilePath );
                newFolder.mkdir();
                if( newFolder.exists() && newFolder.canWrite() )
                {
                    mFile = new File( newFolder.getAbsolutePath() + "/" + mFileName );
                    if( true == mFile.exists() )
                    {
                        mFile.delete();
                        if( DEBUG )
                            Log.d( LOG, "FILE EXIST" );
                    }
                    mFile.createNewFile();
                }
                else
                {
                    return false;
                }
            }
        }
        catch( Exception e )
        {
            return false;
        }
        return true;
    }
    
// 파일 쓰기
    private boolean writeFile()
    {
        byte[] fileContent = "1234".getBytes();
        FileOutputStream fos = null;
       
        try
        {
            fos = new FileOutputStream( mFile );
            fos.write( fileContent );
            fos.close();
            fos = null;
            mIsWrite = true;
            mSdWrite.setText( R.string.sd_write_ok );
            if( DEBUG )
                Log.d( LOG, "MEDIA_WROTE" );
        }
        catch( Exception e )
        {
            if( fos != null )
            {
                try
                {
                    fos.close();
                }
                catch( IOException e1 )
                {
                    e1.printStackTrace();
                }
                fos = null;
            }
            mIsWrite = false;
            mSdWrite.setText( R.string.sd_write_fail );
            e.printStackTrace();
            return false;
        }
        return true;
    }
    
// 파일 읽기
    private boolean readFile()
    {
        FileInputStream fis = null;
       
        try
        {
            fis = new FileInputStream( mFile );
            fis.read( mTestFile );
            fis.close();
            fis = null;
            mIsRead = true;
            mSdRead.setText( R.string.sd_read_ok );
            if( DEBUG )
                Log.d( LOG, "MEDIA_READ" );
           
            mFile.delete();
           
            if( DEBUG )
                Log.d( LOG, "MEDIA_DELETED" );
        }
        catch( Exception e )
        {
            if( fis != null )
            {
                try
                {
                    fis.close();
                }
                catch( IOException e1 )
                {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                fis = null;
            }
            mIsRead = true;
            mSdRead.setText( R.string.sd_read_fail );
           
            return false;
        }
        return true;
    }
Posted by 컴투