Saving file to phone instead of SD card

偶尔善良 提交于 2019-12-01 22:14:00

Got it by changing

Environment.getExternalStorageDirectory() + "/Message.xml"

into

Environment.getDataDirectory() + "/data/com.companyname.appname/files/Message.xml"

First you should check if External Storage (SD card) is available and ready to write to by checking getExternalStorageState(). Read more here: http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

Then if SD card not available you can write to internal storage. Read more here for example on how to write and read: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

Try andriods Data-Storage.

Hope this helps.

You can use openFileOutput to get an access to the internal storage. For more info, you should read the documentation on internal storage.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!