Bundle bundle;
//set data to bundle
//......
File file = new File(context.getFilesDir().getAbsolutePath() + "/data/");
FileOutputStream fos;
try {
fos = new FileOutputStream(file);
//fos.write
fos.close();
} catch (FileNotFoundException exp1) {
exp1.printStackTrace();
} catch ( IOException exp2) {
exp2.printStackTrace();
}
我有上述的代码。我想要做的就是将bundle保存到文件中。我找到了write方法,但我只能传递byte[]而不能传递bundle。我试图将bundle转换为byte[],但没有成功。我该怎么做才能让它工作?最有效的方法是什么?