package com.android.word.net;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.app.Activity;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class AndroidWordNetActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AssetManager as = getResources().getAssets();
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
try {
try {
InputStream is = as.open("asset_file.txt");
br = new BufferedReader(new InputStreamReader(is));
String str;
while ((str = br.readLine()) != null) {
sb.append(str + "\n");
}
} finally {
if (br != null)
br.close();
}
} catch (IOException e) {
Toast.makeText(this, "読み込み失敗", Toast.LENGTH_SHORT).show();
}
TextView label = (TextView) this.findViewById(R.id.textView1);
label.setText(sb.toString());
}
}
2011年12月25日日曜日
assetsフォルダのファイル利用
assetsフォルダに入れられるファイルサイズは1MBの制限がある。
関連記事
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿