###前提・実現したいこと
UnityでAndroidアプリを作成しています。
外部SDカードのファイルにWriteAllTextで上書き保存時に以下のエラーが発生してしまいます。
どのように
対応すれば、エラーなく書き込むことができますか。
###発生している問題・エラーメッセージ
I/Unity ( 1980): I/Unity ( 1980): UnauthorizedAccessException: Access to the path "/storage/sdcard1/json/Setting.json" is denied. I/Unity ( 1980): at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0 I/Unity ( 1980): at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0 I/Unity ( 1980): at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize) [0x00000] in <filename unknown>:0 I/Unity ( 1980): at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding) [0x00000] in <filename unknown>:0 I/Unity ( 1980): at System.IO.File.WriteAllText (System.String path, System.String contents, System.Text.Encoding encoding) [0x00000] in <filename unknown>:0 I/Unity ( 1980): at System.IO.File.WriteAllText (System.String path, System.String contents) [0x00000] in <filename unknown>:0 I/Unity ( 1980): at SettingManager.SaveButton_Click () [0
###該当のソースコード
C#
1System.IO.File.WriteAllText (mPath, mText);
###試したこと
AndroidManifestに"android.permission.WRITE_EXTERNAL_STORAGE"の追加
Unityの[PlayerSetting] -> [OtherSetting] -> [WritePermission] -> [External(SDCard)]の設定
###補足情報(言語/FW/ツール等のバージョンなど)
Unity5.5.0f3
Android 4.4 と 5.1
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/16 08:22
退会済みユーザー
2017/02/16 08:28