关于android里的文件创建及读写问题
来源:互联网 发布:excel access sql 编辑:程序博客网 时间:2024/05/31 19:14
一 在SD卡创建并读写文件
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>申请权限
File newxmlfile = newFile(Environment.getExternalStorageDirectory(),"aaa.xml"); try{ if(!newxmlfile.exists()) newxmlfile.createNewFile(); }catch(IOException e){ Log.e("IOException", "exception in createNewFile() method"); return; } //we have to bind the new file with a FileOutputStream FileOutputStream fileos =null; try{ fileos = new FileOutputStream(newxmlfile); }catch(FileNotFoundExceptione){ Log.e("FileNotFoundException", "can't createFileOutputStream"); return; }
二
FileOutputStream fileos =null; try{ fileos=context.openFileOutput("aaa.xml",Context.MODE_WORLD_READABLE); }catch(FileNotFoundException e){ Log.e("FileNotFoundException", "can't createFileOutputStream"); return; }
FileInputStream fis=null; try{ fis=context.openFileInput("aaa.xml"); }catch(FileNotFoundException e){ Log.e("FileNotFoundException", "Couldn't find or open policyfile"); return; }
方法二(普通方法)
FilepolicyFile = new File("/data/aaa.xml"); FileInputStream fis=null; try { fis = new FileInputStream(policyFile); } catch (FileNotFoundException e) { Log.w(TAG, "Couldn't find or open policy file " +policyFile); return null; }
- 关于android里的文件创建及读写问题
- 关于android里的文件创建及读写问题
- 关于android里的文件创建及读写问题
- 关于文件的读写问题
- Android开发中关于文件读写的一个小问题
- 关于加载android里 .so文件的问题
- linux下面php文件和文件夹的创建及读写问题
- 关于文件读写冲突问题的探索
- 关于ini文件读写的一些问题
- 关于在Eclipse里创建的jsp文件中输入中文存储时报错的问题.
- 读写文件及创建目录
- 【MFC】:MFC关于文件读写的代码及结构体的错误问题
- Android 中关于文件的读写操作
- Android的读写文件及权限设置
- Android应用程序里创建文件及改变权限
- 关于android读写sdcard的权限问题
- 关于Android Studio里的Gradle文件
- android 关于蓝牙间通信,及RFID设备读写芯片问题的处理方案
- 分享一下,C 语言free 函数的原理
- linux下添加,删除,修改,查看用户和用户组
- HTTP协议flowplayer拖动播放FLV的实现
- Android权限机制
- uva 1398 - Meteor 模拟 99
- 关于android里的文件创建及读写问题
- Linux 定时执行任务方法
- 京 ICP 证 070598 号
- 什么叫AP
- [leetcode刷题系列]Median of Two Sorted Arrays
- HTTP协议下flowplayer实现任意拖动播放
- 将文本拆分到不同的单元格中
- oracle11g数据导出不全的问题
- 基于jquery实现一张图片点击鼠标放大再点缩小