Edit of
Android File Access
[
Front page
] [
Edit
|
Diff
|
Backup
|
Upload
|
Reload
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
-- Use page as template --
ALP
Acquisition of terminal information
Android Activity
Android App. Widget
Android AppWidget
Android Build
Android Button
Android Buttonの属性
Android Camera
Android Change Icon
Android Check Box
Android Content Provier
Android DDMS
Android Data
Android Debug
Android Design
Android Dialog
Android Digital Signature
Android Distribution
Android Edit Text
Android Environment
Android Event Handling
Android File Access
Android GUI
Android GUI部品
Android Graphic
Android Image
Android ImageView
Android Intent
Android Internationalization
Android Layout
Android List View
Android Log
Android Memory
Android Menu
Android Mobile Ads
Android Movie
Android Music
Android Network
Android Notification
Android Open GL
Android Preference
Android Radio Button
Android Resource
Android SDK
Android Screen Transition
Android Security
Android Sensor
Android Service
Android Telephony
Android Text display
Android TextViewの属性
Android Toast
Android Touch Event
Android URI
Android View
Android Viewの属性
Android Volume Settings
Android Widget
Android directory composition
Android その他 デバイス
Android アプリウィジェット
Android アプリケーションへのデジタル署名
Android ダイアログ
Android デバッグ
Android バックライト
Android ファイルシステム
Android マニフェストファイル
Android ログ
Android 乱数を生成
Android 方位センサー
Android 標準アプリ動作
Android 気をつけたい動作
Android 画面の向き
Android 製品動向
Android 製品動向 - 端末一覧
Android 顔認識
Android Widget拡張
Android-GAEé£æº
Android-GAE連携
Android2
Architecture Overview
BracketName
Criteria In philadelphia truck accident - Guidelines
Doja
Doja Tips
Establishing Fast Methods For personal injury philadelphia
FormattingRules
FrontPage
Google App Engine
Help
InterWiki
InterWikiName
InterWikiSandBox
Introduction to Android
LevelHeadedPlansOfBurnsSomeUsefulGuidance
Limo
Media
MeeGo
MenuBar
Mobile App 入門
Mobile Application Guide
Mobile Application 入門
Open GL ES
Open+GL+ES
PHP
PrimaryAspectsForShoulderDystociaObtainingHelp
PukiWiki
PukiWiki/1.4
PukiWiki/1.4/Manual
PukiWiki/1.4/Manual/Plugin
PukiWiki/1.4/Manual/Plugin/A-D
PukiWiki/1.4/Manual/Plugin/E-G
PukiWiki/1.4/Manual/Plugin/H-K
PukiWiki/1.4/Manual/Plugin/L-N
PukiWiki/1.4/Manual/Plugin/O-R
PukiWiki/1.4/Manual/Plugin/S-U
PukiWiki/1.4/Manual/Plugin/V-Z
SandBox
Some Facts For 2012 - Central Elements For jacksonville beach real estate listings
Some Helpful Considerations On Factors Of philadelphia truck accident attorney
ThePossibilitiesForItemsOfbocaratoncaraccidentlawyer
WikiEngines
WikiName
WikiWikiWeb
YukiWiki
チェックボックスAndroid チェックボックス
''[[MobileApp>Mobile Application Guide]]'' > ''[[Android>Introduction to Android]]'' > ''File Access'' ~ *ファイルアクセスの方法 [#f2010d23] **ファイルアクセスの概要 [#wa3e707d] Androidではjava.ioパッケージの標準ioが使用できる。ので、特に難しくない~ ・テキストファイルを読み書きする場合は、FileReader() / FileWriter()~ ・そうでない場合は、FileInputStream() / FileOutputStream()を使う。 ~ **ファイル読込 [#h94e64a7] openFileInput() でStreamを取得し、read()で読み込む // テキストの読込 public void loadText() throws IOException{ String path = "data.txt"; FileInputStream input = this.openFileInput(path); byte[] buffer = new byte[1000]; input.read(buffer); String s = new String(buffer).trim(); edit.setText(s); input.close(); } ~ **ファイル書込 [#rd8b0e48] openFileOutput() で Streamを取得し、write()で書き込む // テキストの保存 public void saveText(String data) throws IOException{ String path = "data.txt"; FileOutputStream output = this.openFileOutput(path, Context.MODE_WORLD_READABLE); output.write(data.getBytes()); output.close(); } ~ ~ **SDカード へのアクセス[#y8b59eb6] +外部ストレージのパスを取得する +java.io.File の File クラスのインスタンスを生成。コンストラクタに "1."のパスとファイル名を指定。 +File Output Stream(File Input Stream)クラスのインスタンスを生成。コンストラクタに File クラスのインスタンスを指定。 +File Output Stream クラスの write() を使ってデータを書き込む。 書き込みが終わったら、 close() 。 -内部フラッシュでは/data/data/パッケージ名/xxxxにしかアクセスできない~ (例:/data/data/com.sudden Anger System/xxx) -内部フラッシュは容量が小さい -パスを意識すべきではない。(Contextクラスのメソッドは"/data/data/パッケージ名"の部分を解決してくれるので、それを使う) ~ AndroidでSDカードにアクセスするサンプル File file = Environment.getExternalStorageDirectory(); File file = File("/sdcard"); ~ ~ **ディレクトリ構成について [#i1cc49d0] 工事中 ~ **参考 [#o53f4dce] Asset Managerの件~ http://blog.haw.co.jp/android/?p=42~ http://android.g.hatena.ne.jp/n4_t/20090622/1245689916~ http://groups.google.co.jp/group/android-group-japan/browse_thread/thread/567326c74ebade70 ~ ~ わかりやすかったHP~ http://libro99.appspot.com/index3?id=36 ~ ~ ''[[Back>Introduction to Android]]''
Do not change timestamp
''[[MobileApp>Mobile Application Guide]]'' > ''[[Android>Introduction to Android]]'' > ''File Access'' ~ *ファイルアクセスの方法 [#f2010d23] **ファイルアクセスの概要 [#wa3e707d] Androidではjava.ioパッケージの標準ioが使用できる。ので、特に難しくない~ ・テキストファイルを読み書きする場合は、FileReader() / FileWriter()~ ・そうでない場合は、FileInputStream() / FileOutputStream()を使う。 ~ **ファイル読込 [#h94e64a7] openFileInput() でStreamを取得し、read()で読み込む // テキストの読込 public void loadText() throws IOException{ String path = "data.txt"; FileInputStream input = this.openFileInput(path); byte[] buffer = new byte[1000]; input.read(buffer); String s = new String(buffer).trim(); edit.setText(s); input.close(); } ~ **ファイル書込 [#rd8b0e48] openFileOutput() で Streamを取得し、write()で書き込む // テキストの保存 public void saveText(String data) throws IOException{ String path = "data.txt"; FileOutputStream output = this.openFileOutput(path, Context.MODE_WORLD_READABLE); output.write(data.getBytes()); output.close(); } ~ ~ **SDカード へのアクセス[#y8b59eb6] +外部ストレージのパスを取得する +java.io.File の File クラスのインスタンスを生成。コンストラクタに "1."のパスとファイル名を指定。 +File Output Stream(File Input Stream)クラスのインスタンスを生成。コンストラクタに File クラスのインスタンスを指定。 +File Output Stream クラスの write() を使ってデータを書き込む。 書き込みが終わったら、 close() 。 -内部フラッシュでは/data/data/パッケージ名/xxxxにしかアクセスできない~ (例:/data/data/com.sudden Anger System/xxx) -内部フラッシュは容量が小さい -パスを意識すべきではない。(Contextクラスのメソッドは"/data/data/パッケージ名"の部分を解決してくれるので、それを使う) ~ AndroidでSDカードにアクセスするサンプル File file = Environment.getExternalStorageDirectory(); File file = File("/sdcard"); ~ ~ **ディレクトリ構成について [#i1cc49d0] 工事中 ~ **参考 [#o53f4dce] Asset Managerの件~ http://blog.haw.co.jp/android/?p=42~ http://android.g.hatena.ne.jp/n4_t/20090622/1245689916~ http://groups.google.co.jp/group/android-group-japan/browse_thread/thread/567326c74ebade70 ~ ~ わかりやすかったHP~ http://libro99.appspot.com/index3?id=36 ~ ~ ''[[Back>Introduction to Android]]''
View Text Formatting Rules