我看过使用这种方法写入内部存储的方式。
public void storeSerializedObject(MyObject theObject) {
FileOutputStream fileOut = null;
String fileName = theObject.getName();
try {
fileOut = context.getApplicationContext().openFileOutput(
fileName + ".ser", Context.MODE_PRIVATE);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(theObject);
out.close();
fileOut.close();
} catch (IOException i) {
i.printStackTrace();
}
}
我想把 theObject 放到某个新的指定目录中。
然后在该目录中搜索所有.ser文件,并对每个对象进行反序列化。
所以基本上,你会如何做呢?
另外,使用以上文件存储方法,有没有办法检查默认的未命名位置,以获取其内容中所有文件名的列表?