当前位置: 代码迷 >> Android >> 【android开发】android创办与读取文件
  详细解决方案

【android开发】android创办与读取文件

热度:10   发布时间:2016-05-01 16:19:59.0
【android开发】android创建与读取文件

1:windows下不可以直接访问在android环境下创建的文件,必须这样操作才可以看见创建的文件

  步骤如下:

  adb shell -> ls ->cd data -> cd 项目的包名->cd files -> ls ->这样就会看见你创建的文件

  2:在android下创建一个 android.txt 文件

  FileOutputStream fos = this.openFileOutput("android.txt",MODE_APPEND);

  fos.write("".getByte());

  fos.flush();

  fos.close();

  .........................

  3:在android下读取上面创建的文件

  FileInputStream fis = this.openFileInput("android.txt");

  4:读取 android资源下的文件 必须在res下建一个raw文件夹 放入一个文件 android.txt

  InputStream is = getResource().openRawResource(R.raw.android);

  相关解决方案