android 获取配置文件信息
2013-08-05 03:06
441 查看
public class MainActivity extends Activity {
private EditText myquestion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** 全屏设置,隐藏窗口所有装饰 */
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
Log.d("Show main page.","ok");
myquestion=(EditText)findViewById(R.id.editTextQuestion);
AssetManager assetManager = getAssets();
InputStream inputStream = null;
try {
inputStream = assetManager.open("questions.txt");
} catch (IOException e) {
Log.e("tag", e.getMessage());
}
String s = readTextFile(inputStream);
myquestion.setText(s);
}
private String readTextFile(InputStream inputStream) {
String outputStream = new String();
byte buf[] = new byte[1024];
int len;
try {
while ((len = inputStream.read(buf)) != -1) {
outputStream = outputStream + EncodingUtils.getString(buf,"UTF-8");
}
inputStream.close();
} catch (IOException e) {
}
return outputStream;
}
}
private EditText myquestion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** 全屏设置,隐藏窗口所有装饰 */
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
Log.d("Show main page.","ok");
myquestion=(EditText)findViewById(R.id.editTextQuestion);
AssetManager assetManager = getAssets();
InputStream inputStream = null;
try {
inputStream = assetManager.open("questions.txt");
} catch (IOException e) {
Log.e("tag", e.getMessage());
}
String s = readTextFile(inputStream);
myquestion.setText(s);
}
private String readTextFile(InputStream inputStream) {
String outputStream = new String();
byte buf[] = new byte[1024];
int len;
try {
while ((len = inputStream.read(buf)) != -1) {
outputStream = outputStream + EncodingUtils.getString(buf,"UTF-8");
}
inputStream.close();
} catch (IOException e) {
}
return outputStream;
}
}
相关文章推荐
- 简单使用boost property_tree组件获取配置文件信息
- Android--数据存储方式--文件的保存和获取存储用户信息--《便签》
- 获取配置类中的文件信息
- Android中获取apk文件包名,名称,图标等信息
- Android 从清单配置文件元数据中获取值
- android--------根据文件路径使用File类获取文件相关信息
- android获取APK文件,及应用内部签名信息方法
- 【Android】获取手机中已安装apk文件信息(PackageInfo、ResolveInfo)(应用图片、应用名、包名等) .
- Android 获取音乐文件的信息
- Android获取手机配置信息
- Android平台中应该如何获取音乐文件的信息
- Android检测版本更新(读取apk配置文件中的版本信息)
- C# 如何获取配置文件里的节点信息
- 类项目中的配置文件app.config在打包安装后的信息获取的问题
- Android平台中应该如何获取音乐文件的信息
- C#使用单例模式类获取本地程序目录下XML文件中的配置信息
- 如何获取XML文件里配置的信息
- 【Android】获取手机中已安装apk文件信息(PackageInfo、ResolveInfo)(应用图片、应用名、包名等)
- 【Android Developers Training】 39. 获取文件信息
- Android 获取文本内容及配置信息