【发布时间】:2015-10-21 18:07:00
【问题描述】:
我是 android 开发的新手,我正在创建简单的蓝牙应用程序,它可以接收 xml 文件并将 xml 文件值保存到数据库。但是如何从字节数组接收 xml 文件?可能吗?在 searchinf 之后,我找到了 this question 并基于这个问题,我尝试将字节数组保存到文件中。但是我需要如何测试呢?我在手机中找不到我的文件。
case Constants.MESSAGE_READ:
byte[] readBuffer = (byte[]) msg.obj;
try {
String path = activity.getFilesDir() + "/myFile.xml";
Log.d("MuTestClass", path);
FileOutputStream stream = new FileOutputStream(path);
stream.write(readBuffer);
stream.close();
} catch (Exception e1) {
e1.printStackTrace();
}
break;
【问题讨论】: