posted @ 2016-05-25 10:10 Eric Song 閱讀(267) | 評論 (0) | 編輯 收藏
posted @ 2011-02-19 12:34 Eric Song 閱讀(1566) | 評論 (2) | 編輯 收藏
posted @ 2010-06-08 00:15 Eric Song 閱讀(2016) | 評論 (1) | 編輯 收藏
SharedPreferences
To get a SharedPreferences object for your application, use one of two methods:
getSharedPreferences()
getPreferences()
To write values:
edit()
SharedPreferences.Editor
putBoolean()
putString()
commit()
To read values, use SharedPreferences methods such as getBoolean() and getString().
getBoolean()
getString()
Here is an example that saves a preference for silent keypress mode in a calculator:
posted @ 2010-06-07 17:18 Eric Song 閱讀(417) | 評論 (0) | 編輯 收藏
首先內部存儲路徑為/data/data/youPackageName/,下面講解的各路徑都是基于你自己的應用的內部存儲路徑下。所有內部存儲中保存的文件在用戶卸載應用的時候會被刪除。 一、 files 1. Context.getFilesDir(),該方法返回/data/data/youPackageName/files的File對象。 2. Context.openFileInput()與Context.openFileOutput(),只能讀取和寫入files下的文件,返回的是FileInputStream和FileOutputStream對象。 3. Context.fileList(),返回files下所有的文件名,返回的是String[]對象。 4. Context.deleteFile(String),刪除files下指定名稱的文件。 二、cache 1. Context.getCacheDir(),該方法返回/data/data/youPackageName/cache的File對象。 三、custom dir
posted @ 2010-06-07 16:28 Eric Song 閱讀(2022) | 評論 (1) | 編輯 收藏
經過不斷的測試最終得到3個結果: 1.適用于模擬器和OPhone
2.適用于Hero(未測試是否支持其他HTC手機)
3.目前為止在多數手機上工作正常的代碼
需要注意的一個問題是之前一直用Uri指向自己開發應用的data文件夾下的文件,始終無法成功,最終換成sdcard就OK了,看來還是權限的問題。
posted @ 2010-05-19 19:20 Eric Song 閱讀(1536) | 評論 (1) | 編輯 收藏
posted @ 2009-12-14 13:36 Eric Song 閱讀(1487) | 評論 (0) | 編輯 收藏
posted @ 2009-12-09 21:49 Eric Song 閱讀(3993) | 評論 (0) | 編輯 收藏
posted @ 2009-11-18 13:10 Eric Song 閱讀(409) | 評論 (0) | 編輯 收藏
posted @ 2009-10-18 22:59 Eric Song 閱讀(255) | 評論 (0) | 編輯 收藏