Я пишу свое первое приложение для Android.И я хотел использовать db4o, просто потому, что никогда не использовал его раньше.Я просто пытаюсь открыть / создать базу данных. Все работает нормально, когда я запускаю это на виртуальном устройстве.Но когда я собираюсь на свое реальное устройство, я всегда получаю исключения, написанные ниже:
...ActivityClass{
private void deleteDB() {
DatabaseHandler db = new DatabaseHandler();
db.open(getString(R.string.database));
db.deleteAll();
db.close();
}
}....
The R.string.database = /data/data/de.workingtimemanager.urb/databases/WTM.db
my package = de.workingtimemanager.urb
public class DatabaseHandler {
private ObjectContainer database;
public DatabaseHandler() {}
public void open(String name) {
EmbeddedConfiguration conf = Db4oEmbedded.newConfiguration();
conf.common().objectClass(User.class).cascadeOnDelete(true);
conf.common().objectClass(User.class).cascadeOnUpdate(true);
conf.common().objectClass(Project.class).cascadeOnDelete(true);
conf.common().objectClass(Project.class).cascadeOnUpdate(true);
database = Db4oEmbedded.openFile(conf, name);
}
}
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.workingtimemanager.urb/de.workingtimemanager.urb.WorkingTimeManagerActivity}: com.db4o.ext.Db4oIOException: /data/data/de.workingtimemanager.urb/databases/WTM.db (No such file or directory)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.os.Handler.dispatchMessage(Handler.java:99)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.os.Looper.loop(Looper.java:123)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.app.ActivityThread.main(ActivityThread.java:3691)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at java.lang.reflect.Method.invokeNative(Native Method)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at java.lang.reflect.Method.invoke(Method.java:507)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at dalvik.system.NativeStart.main(Native Method)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): Caused by: com.db4o.ext.Db4oIOException: /data/data/de.workingtimemanager.urb/databases/WTM.db (No such file or directory)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.io.RandomAccessFileFactory.newRandomAccessFile(RandomAccessFileFactory.java:26)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.io.FileStorage$FileBin.<init>(FileStorage.java:43)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.io.FileStorage.open(FileStorage.java:22)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.io.StorageDecorator.open(StorageDecorator.java:27)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.io.CachingStorage.open(CachingStorage.java:52)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.internal.IoAdaptedObjectContainer.openImpl(IoAdaptedObjectContainer.java:57)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.internal.ObjectContainerBase$1.run(ObjectContainerBase.java:140)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.foundation.DynamicVariable.with(DynamicVariable.java:54)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.foundation.Environments.runWith(Environments.java:28)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.internal.ObjectContainerBase.withEnvironment(ObjectContainerBase.java:161)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.internal.ObjectContainerBase.open(ObjectContainerBase.java:131)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.internal.IoAdaptedObjectContainer.<init>(IoAdaptedObjectContainer.java:35)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.internal.ObjectContainerFactory.openObjectContainer(ObjectContainerFactory.java:18)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.Db4oEmbedded.openFile(Db4oEmbedded.java:65)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at de.workingtimemanager.urb.db.DatabaseHandler.open(DatabaseHandler.java:33)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at de.workingtimemanager.urb.WorkingTimeManagerActivity.deleteDB(WorkingTimeManagerActivity.java:22)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at de.workingtimemanager.urb.WorkingTimeManagerActivity.onCreate(WorkingTimeManagerActivity.java:15)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): ... 11 more
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): Caused by: java.io.FileNotFoundException: /data/data/de.workingtimemanager.urb/databases/WTM.db (No such file or directory)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:132)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:173)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): at com.db4o.io.RandomAccessFileFactory.newRandomAccessFile(RandomAccessFileFactory.java:19)
11-01 13:38:36.385: ERROR/AndroidRuntime(4774): ... 29 more