一度に作成できるディレクトリの数にAndroidの制限はありますか?私は実際にデータベースをsub-sub-sub-directoryに保存しようとしているからです。だから私は次のコードを使用していました。
DATABASE_NAME = Environment.getExternalStorageDirectory() + "/AllDatabases/" + comp
+ "/Balance/" + wy + ".db";
最初に「AllDatabases」という名前のフォルダーを作成し、次に変数「comp」の特定の値を含むサブフォルダーを作成すると、コードは完全に正常に機能します(たとえば「lol」)。
where comp = lol
次に、そこにデータベースを正常に作成します。しかし、作成したフォルダーを再度削除し、DATABASE_NAMEに値を割り当てている上記のステートメントを使用して直接ビルドしようとすると、アプリケーションが強制的に閉じられます。これはLogCatが示すものです...
01-21 18:03:30.194: E/Database(19098): sqlite3_open_v2("/mnt/sdcard/lol/MyLedgers/2012-2013.db", &handle, 6, NULL) failed
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): Couldn't open /mnt/sdcard/lol/MyLedgers/2012-2013.db for writing (will try read-only):
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): android.database.sqlite.SQLiteException: unable to open database file
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1921)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:883)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:960)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:953)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:548)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:158)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at com.balance.start.LedgerInfoDB.opentoread(LedgerInfoDB.java:78)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at com.balance.start.MainView.onCreate(MainView.java:101)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2633)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2685)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.app.ActivityThread.access$2300(ActivityThread.java:126)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.os.Looper.loop(Looper.java:123)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at android.app.ActivityThread.main(ActivityThread.java:4633)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at java.lang.reflect.Method.invokeNative(Native Method)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at java.lang.reflect.Method.invoke(Method.java:521)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-21 18:03:30.254: E/SQLiteOpenHelper(19098): at dalvik.system.NativeStart.main(Native Method)
01-21 18:03:30.254: E/Database(19098): sqlite3_open_v2("/mnt/sdcard/chomu/MyLedgers/2012-2013.db", &handle, 1, NULL) failed
01-21 18:03:30.264: W/dalvikvm(19098): threadid=1: thread exiting with uncaught exception (group=0x400207d8)
01-21 18:03:30.264: E/AndroidRuntime(19098): FATAL EXCEPTION: main
01-21 18:03:30.264: E/AndroidRuntime(19098): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.balance.start/com.balance.start.MainView}: android.database.sqlite.SQLiteException: unable to open database file
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2685)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.app.ActivityThread.access$2300(ActivityThread.java:126)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.os.Looper.loop(Looper.java:123)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.app.ActivityThread.main(ActivityThread.java:4633)
01-21 18:03:30.264: E/AndroidRuntime(19098): at java.lang.reflect.Method.invokeNative(Native Method)
01-21 18:03:30.264: E/AndroidRuntime(19098): at java.lang.reflect.Method.invoke(Method.java:521)
01-21 18:03:30.264: E/AndroidRuntime(19098): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
01-21 18:03:30.264: E/AndroidRuntime(19098): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-21 18:03:30.264: E/AndroidRuntime(19098): at dalvik.system.NativeStart.main(Native Method)
01-21 18:03:30.264: E/AndroidRuntime(19098): Caused by: android.database.sqlite.SQLiteException: unable to open database file
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1921)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:883)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:168)
01-21 18:03:30.264: E/AndroidRuntime(19098): at com.balance.start.LedgerInfoDB.opentoread(LedgerInfoDB.java:78)
01-21 18:03:30.264: E/AndroidRuntime(19098): at com.balance.start.MainView.onCreate(MainView.java:101)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-21 18:03:30.264: E/AndroidRuntime(19098): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2633)
01-21 18:03:30.264: E/AndroidRuntime(19098): ... 11 more
代替案を提案するか、この制限を回避する方法を教えてください。
ありがとう。:)