【发布时间】:2012-10-11 08:47:07
【问题描述】:
我正在开发 Android 应用,我需要保存和加载功能。
我想通过此功能将重要数据保存在私有应用存储中:
public static void save(Object file, String fileName, Context context)
throws IOException, FileNotFoundException {
FileOutputStream fos = context.openFileOutput(fileName,
context.MODE_PRIVATE);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(file);
oos.flush();
oos.close();
fos.close();
System.out.println(TAG + ": File saved successful!");
}
我还编写了加载数据的方法。 这很有效,因为我知道文件的确切名称。
我现在需要动态保存文件,动态生成名称。 如何列出保存在昂贵的应用程序存储中的文件? 所以我可以加载准确的吗?
【问题讨论】: