DB40 データベースから返されたオブジェクトを listviewactivity のリストに入力しようとしていますが、アプリがクラッシュし続け、その理由がよくわかりません。
LogCat の読み方を知っていて、そこに書かれていることから理解できると助かります..- 大まかな理解はできますが、何が問題なのか正確にはわかりません。
public class AndrochieveActivity extends ListActivity {
private List<Achievement> achieves;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ObjectContainer db = Db4oEmbedded.openFile("achievements.db4o");
try{
achieves = db.query(Achievement.class);
} finally {
db.close();
}
setListAdapter(new ArrayAdapter<Achievement>(this, R.layout.achievelist, achieves) {
@Override
public View getView(int pos, View cView, ViewGroup parent) {
View row = mInflater.inflate(R.layout.achievelist, null);
TextView title = (TextView) row.findViewById(R.id.title);
title.setText(getItem(pos).GetTitle());
TextView desc = (TextView)row.findViewById(R.id.desc);
desc.setText(getItem(pos).GetDescription());
TextProgressBar prog = (TextProgressBar)row.findViewById(R.id.prog);
prog.setProgress(0);
prog.setMax(getItem(pos).GetMax());
return row;
}
});
}
本質的にそれを台無しにするものは何も見ていません。Db4oEmbedded.openFile は、終了しない場合はファイルを作成する必要がありますが、次のように、logcat で一連のファイル読み取りエラーが発生し続けます。
11-29 14:21:44.359: D/AndroidRuntime(19396): Shutting down VM
11-29 14:21:44.359: W/dalvikvm(19396): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
11-29 14:21:44.389: E/AndroidRuntime(19396): FATAL EXCEPTION: main
11-29 14:21:44.389: E/AndroidRuntime(19396): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.megalon.androchieve/com.megalon.androchieve.AndrochieveActivity}: com.db4o.ext.Db4oIOException: /achievements.db4o (Read-only file system)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1849)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1870)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1051)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.os.Looper.loop(Looper.java:150)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.app.ActivityThread.main(ActivityThread.java:4312)
11-29 14:21:44.389: E/AndroidRuntime(19396): at java.lang.reflect.Method.invokeNative(Native Method)
11-29 14:21:44.389: E/AndroidRuntime(19396): at java.lang.reflect.Method.invoke(Method.java:507)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
11-29 14:21:44.389: E/AndroidRuntime(19396): at dalvik.system.NativeStart.main(Native Method)
11-29 14:21:44.389: E/AndroidRuntime(19396): Caused by: com.db4o.ext.Db4oIOException: /achievements.db4o (Read-only file system)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.io.RandomAccessFileFactory.newRandomAccessFile(RandomAccessFileFactory.java:26)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.io.FileStorage$FileBin.<init>(FileStorage.java:43)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.io.FileStorage.open(FileStorage.java:22)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.io.StorageDecorator.open(StorageDecorator.java:27)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.io.CachingStorage.open(CachingStorage.java:52)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.internal.IoAdaptedObjectContainer.openImpl(IoAdaptedObjectContainer.java:57)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.internal.ObjectContainerBase$1.run(ObjectContainerBase.java:140)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.foundation.DynamicVariable.with(DynamicVariable.java:54)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.foundation.Environments.runWith(Environments.java:28)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.internal.ObjectContainerBase.withEnvironment(ObjectContainerBase.java:161)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.internal.ObjectContainerBase.open(ObjectContainerBase.java:131)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.internal.IoAdaptedObjectContainer.<init>(IoAdaptedObjectContainer.java:35)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.internal.ObjectContainerFactory.openObjectContainer(ObjectContainerFactory.java:18)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.Db4oEmbedded.openFile(Db4oEmbedded.java:65)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.Db4oEmbedded.openFile(Db4oEmbedded.java:76)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.megalon.androchieve.AndrochieveActivity.onCreate(AndrochieveActivity.java:45)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
11-29 14:21:44.389: E/AndroidRuntime(19396): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1813)
11-29 14:21:44.389: E/AndroidRuntime(19396): ... 11 more
11-29 14:21:44.389: E/AndroidRuntime(19396): Caused by: java.io.FileNotFoundException: /achievements.db4o (Read-only file system)
11-29 14:21:44.389: E/AndroidRuntime(19396): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
11-29 14:21:44.389: E/AndroidRuntime(19396): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
11-29 14:21:44.389: E/AndroidRuntime(19396): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:132)
11-29 14:21:44.389: E/AndroidRuntime(19396): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:173)
11-29 14:21:44.389: E/AndroidRuntime(19396): at com.db4o.io.RandomAccessFileFactory.newRandomAccessFile(RandomAccessFileFactory.java:19)
11-29 14:21:44.389: E/AndroidRuntime(19396): ... 28 more
11-29 14:21:44.419: D/dalvikvm(19396): GC_CONCURRENT freed 308K, 49% free 2900K/5639K, external 0K/0K, paused 2ms+3ms
11-29 14:21:46.310: D/Process(19396): killProcess, pid=19396
11-29 14:21:46.310: D/Process(19396): dalvik.system.VMStack.getThreadStackTrace(Native Method)
11-29 14:21:46.320: D/Process(19396): java.lang.Thread.getStackTrace(Thread.java:745)
11-29 14:21:46.320: D/Process(19396): android.os.Process.killProcess(Process.java:797)
11-29 14:21:46.320: D/Process(19396): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:108)
11-29 14:21:46.320: D/Process(19396): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:854)