把文件存入SD卡中

首先加入读写权限

SD卡创建与删除文件权限

<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>

SD卡写入数据权限

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="90px"
android:layout_height="wrap_content"
android:text="文件名称:"
android:textSize="21px"
android:id="@+id/filenamelebal"
/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/filenamelebal"
android:layout_alignTop="@id/filenamelebal"
android:id="@+id/filename"
></EditText>
></RelativeLayout>

<TextView
android:layout_width="90px"
android:layout_height="wrap_content"
android:text="内容:"
android:textSize="21px"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minLines="3"
android:id="@+id/content"
></EditText>
<LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:id="@+id/baocun"
android:text="保存"
android:layout_width="wrap_content"></Button>
<Button
android:text="读取"
android:id="@+id/read"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="退出"
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>

</LinearLayout>
<TextView
android:text="读取内容显示"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>



</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="90px"
android:layout_height="wrap_content"
android:text="文件名称:"
android:textSize="21px"
android:id="@+id/filenamelebal"
/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/filenamelebal"
android:layout_alignTop="@id/filenamelebal"
android:id="@+id/filename"
></EditText>
></RelativeLayout>

<TextView
android:layout_width="90px"
android:layout_height="wrap_content"
android:text="内容:"
android:textSize="21px"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minLines="3"
android:id="@+id/content"
></EditText>
<LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:id="@+id/baocun"
android:text="保存"
android:layout_width="wrap_content"></Button>
<Button
android:text="读取"
android:id="@+id/read"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="退出"
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>

</LinearLayout>
<TextView
android:text="读取内容显示"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>



</LinearLayout>

配置文件


[java]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.luku.file"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="android.test.runner"></uses-library>
<activity android:name=".fileActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.luku.file"
android:label="Test for my app"
></instrumentation>

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.luku.file"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="android.test.runner"></uses-library>
<activity android:name=".fileActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.luku.file"
android:label="Test for my app"
></instrumentation>

</manifest>

摘自 奔跑的蜗牛

更多相关文章

  1. Android应用程序的权限列表
  2. android 的权限
  3. Android10共享文件总是读取不到文件,文件资源不存在!
  4. Android设置弹出键盘与View的交互方式[学习]
  5. (转)Android(安卓)Contacts(一)—— 读取联系人
  6. AndroidManifest.xml【 manifest -> permission-tree 和 manifes
  7. Android(安卓)下载文件至SD卡,并用progressBar显示下载进度
  8. android ListView SimpleAdapter 带图片
  9. Android获取、设置桌面

随机推荐

  1. Android去除系统自带动画的两种方法
  2. adb shell 命令查看android 应用程序 创
  3. android studio中建立assets和jnilibs的
  4. Android 动画 - AlphaAnimation渐变动画
  5. android shape渐近线效果
  6. .net + Android 通信
  7. 采用Scroller实现任意布局的上下左右弹性
  8. How To Set An Android(安卓)Lock Screen
  9. android HDMI:HDMI基础篇
  10. Android 学习 之 资源文件 动态修改strin