關(guān)于Android SDCard存儲(chǔ)的問題
使用Activit的openFileOutput()方法保存文件,文件是放在手機(jī)內(nèi)在上;
注:模擬器中創(chuàng)建SDCard卡鏡像文件,可以在創(chuàng)建模擬器是創(chuàng)建,也可以在Dos窗口中進(jìn)行android SDK安裝路徑tools目錄,輸入如下命令:mksdcard 2048M D:\AndroidTool\sdcard.img
在程序中訪問SDCard,需要如下權(quán)限:
在SDCard中創(chuàng)建與刪除文件的權(quán)限
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
在SDCard中寫入數(shù)據(jù)權(quán)限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
public void saveToSDCard(String filename, String filecontent) throws IOException {
File file = new File(Environment.getExternalStorageDirectory(),filename); //獲取SDCard的路徑
FileOutputStream outStream = new FileOutputStream(file);
outStream.write(filecontent.getBytes());
outStream.close();
}
// 判斷SD卡是否存在并且可以讀寫
//if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
// fs.saveToSDCard(filenamestr, filecontentstr);
// Toast.makeText(getApplicationContext(),R.string.success, 1).show();
// } else {
// Toast.makeText(getApplicationContext(),R.string.sdcarderror, 1).show();
// }
- Android APP與媒體存儲(chǔ)服務(wù)的交互
- 在android開發(fā)中進(jìn)行數(shù)據(jù)存儲(chǔ)與訪問的多種方式介紹
- Android開發(fā)筆記之: 數(shù)據(jù)存儲(chǔ)方式詳解
- android中使用SharedPreferences進(jìn)行數(shù)據(jù)存儲(chǔ)的操作方法
- android開發(fā)基礎(chǔ)教程—文件存儲(chǔ)功能實(shí)現(xiàn)
- Android調(diào)用相機(jī)并將照片存儲(chǔ)到sd卡上實(shí)現(xiàn)方法
- Android應(yīng)用開發(fā)SharedPreferences存儲(chǔ)數(shù)據(jù)的使用方法
- Android編程中的5種數(shù)據(jù)存儲(chǔ)方式
- Android編程實(shí)現(xiàn)手機(jī)自帶內(nèi)部存儲(chǔ)路徑的獲取方法
- Android App中各種數(shù)據(jù)保存方式的使用實(shí)例總結(jié)
相關(guān)文章
Android Studio error: Unable to start the daemon process的解決方
這篇文章主要介紹了在 Android Studio 上新建項(xiàng)目,出現(xiàn) Unable to start the daemon process問題的幾種的解決方法,需要的朋友可以參考下2020-10-10
android實(shí)現(xiàn)輪播圖引導(dǎo)頁
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)輪播圖引導(dǎo)頁,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-09-09
Android實(shí)現(xiàn)第三方授權(quán)登錄、分享以及獲取用戶資料
本篇文章介紹了Android實(shí)現(xiàn)第三方授權(quán)登錄、分享以及獲取用戶資料,詳細(xì)的介紹了第三方授權(quán)登錄的實(shí)現(xiàn)代碼,有需要的朋友可以了解一下。2016-11-11
分享10個(gè)很棒的學(xué)習(xí)Android開發(fā)的網(wǎng)站
我推薦的網(wǎng)站,都是我在學(xué)習(xí)Android 開發(fā)過程中發(fā)現(xiàn)的好網(wǎng)站,給初學(xué)者一些建議,少走一些彎路2015-03-03

