要求:

輸入文件名,文件內(nèi)容分別存儲在手機內(nèi)存和外存中,并且都可以讀去取出來。
步驟:
1.創(chuàng)建一個名為CDsaveFile的Android項目
2.編寫布局文件activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="hhh.exercise.cdsavefile.MainActivity" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_inputFileName" android:textColor="#00ff00" android:textSize="26sp" /> <EditText android:id="@+id/editView_fileName" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:hint="@string/editView_fileName" android:maxLines="1" android:textColor="#ff0000" android:textSize="26sp" /> <requestFocus /> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/textView_inputFileContent" android:textColor="#00ff00" android:textSize="26sp" /> <EditText android:id="@+id/editView_fileContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:hint="@string/editView_fileContent" android:maxLines="2" android:minLines="2" android:textColor="#ff0000" android:textSize="26sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/button_saveToPhone" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/button_saveToPhone" android:textColor="#ff00ff" android:textSize="24sp" /> <Button android:id="@+id/button_readFromPhone" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/button_readFromPhone" android:textColor="#00ffff" android:textSize="24sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/button_saveToSD" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/button_saveToSD" android:textColor="#ff00ff" android:textSize="24sp" /> <Button android:id="@+id/button_readFromSD" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/button_readFromSD" android:textColor="#00ffff" android:textSize="24sp" /> </LinearLayout> <EditText android:id="@+id/editText_showResult" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:maxLines="3" android:minLines="3" android:hint="@string/editText_showResult" android:textColor="#cccc00" android:textSize="30sp" /> </LinearLayout>
網(wǎng)頁題目:Android實現(xiàn)文件存儲并讀取的示例代碼-創(chuàng)新互聯(lián)
瀏覽地址:http://www.yijiale78.com/article48/csighp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、品牌網(wǎng)站建設(shè)、建站公司、外貿(mào)建站、ChatGPT、網(wǎng)站設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容