iphone/android比较学习之──图片、文件、字符串
16lz
2021-01-23
1. 显示图片这两个平台都很简单:
iphone中使用UIImage,告诉它文件path就可以了
android中使用ImageView,同样非常简单
2. 读取文件
iphone中一般借助NSBundle的pathForResource/pathForDocuments获取资源文件路径
而android中使用Context.getResources或者Context.getAssets
获取文件的内容iphone相对简单可以调用NSString的stringWithContentsOfFile,直接读入字符串,或者调用NSData的dataWithContentsOfFile读取binary。
Android中就相对复杂一点了,代码类似
InputStreamis = getAssets().open("***");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String text = new String(byte);
更多相关文章
- 关于build.gradle配置文件详细参数讲解
- eclipse android 设置及修改生成apk的签名文件
- Android 解析XML文件方法
- Android中读写文件
- Android 使用SAX或者DOM或者pull解析XML文件
- Android Launcher2源码分析主布局文件
- 安装APK文件到Android模拟器