当前位置: 代码迷 >> Android >> android开发fileoutputstream有关问题
  详细解决方案

android开发fileoutputstream有关问题

热度:87   发布时间:2016-04-28 04:57:57.0
android开发fileoutputstream问题
android平台上,我用fileoutputstream?fos=new?fileoutputstream("/sdcard/1.txt");老是抛异常filenotfoundexception,但我用?fileoutputstream?fos=openfileoutput("1.txt")就可以,但不能指定路径,小白求大神讲解
------解决方案--------------------
操作存储卡是需要权限的,请加上
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
另外,存储卡的路径最好动态获取,不同手机会不一样。
Environment.getExternalStorageDirectory();
  相关解决方案