2013년 12월 10일 화요일

Resources폴더의 Xml에 접근하는것과 쓰기 문제.

안드로이드 폰에서 Xml 로 정보들을 읽어와 작업한 후에
다시 저장을 하기 위해 아무 생각없이 작업을 했었지만.

문제가 있는 방법이였다.
Resources.Load() 로드 -> Application.dataPath() 저장
방식이였는대

안돼길래 검색을 해보니.
저 경로는 Apk에 직접 접근해 엑세스 하는듯 하다.

거기에 쓰기를 하는건 문제가 있다. 

Application.dataPath should never be used for write access. The reason for this is simple: Application.dataPath points to the actual .apk (which essentially is a .zip file). (I would actually argue that Application.dataPath should not be used for write access on any platform, for various reasons.)

Write access to sd-card is possible just as you described, but as you see you get an UnauthorizedAccessException. The reason for this is that sd-card access is controlled by the manifest permissions. The default manifest created by Unity does not include the android.permission.WRITE_EXTERNAL_STORAGE which enables sd-card access. If you override the manifest you can add this permission yourself.

With Unity 3.2 we added a check-box to control this more easily.