问题是我的内部存储器上的磁盘空间不足,因此写入失败。当异常掉到地板上时,我无法自信地处理它(请参阅http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.3_r1/android /app/ContextImpl.java#3169)。.commit() 调用将返回 false,我可以使用它来处理写入错误,但我不知道失败是由于空间问题还是其他原因。
我怎么知道提交失败的原因是什么?
堆栈跟踪
06-29 20:01:17.507: WARN/ApplicationContext(19221): writeToFile: Got exception:
java.io.IOException: No space left on device
at org.apache.harmony.luni.platform.OSFileSystem.write(Native Method)
at dalvik.system.BlockGuard$WrappedFileSystem.write(BlockGuard.java:171)
at java.io.FileOutputStream.write(FileOutputStream.java:300)
at com.android.internal.util.FastXmlSerializer.flushBytes(FastXmlSerializer.java:212)
at com.android.internal.util.FastXmlSerializer.flush(FastXmlSerializer.java:233)
at com.android.internal.util.FastXmlSerializer.endDocument(FastXmlSerializer.java:183)
at com.android.internal.util.XmlUtils.writeMapXml(XmlUtils.java:185)
at android.app.ContextImpl$SharedPreferencesImpl.writeToFile(ContextImpl.java:3191)
at android.app.ContextImpl$SharedPreferencesImpl.access$800(ContextImpl.java:2756)
at android.app.ContextImpl$SharedPreferencesImpl$1.run(ContextImpl.java:3106)
at android.app.ContextImpl$SharedPreferencesImpl.enqueueDiskWrite(ContextImpl.java:3127)
at android.app.ContextImpl$SharedPreferencesImpl.access$100(ContextImpl.java:2756)
at android.app.ContextImpl$SharedPreferencesImpl$EditorImpl.commit(ContextImpl.java:3049)