开发者

SQLite database creation fails, documentation is unclear

开发者 https://www.devze.com 2022-12-26 04:07 出处:网络
When I add this code to my Android 2.1 Java app, it fails: db=SQLiteDatabase.openOrCreateDatabase(\"Locations\", null);

When I add this code to my Android 2.1 Java app, it fails:

db=SQLiteDatabase.openOrCreateDatabase("Locations", null);

Do I need a special permission to create a database, or can 开发者_如何学编程anybody provide a suggestion how to find out what goes wrong?

Here is the LogCat output:

04-04 15:04:28.702: DEBUG/ddm-heap(703): Got feature list request
04-04 15:04:29.642: ERROR/Database(703): sqlite3_open_v2("Locations", &handle, 6, NULL) failed
04-04 15:04:29.652: DEBUG/AndroidRuntime(703): Shutting down VM
04-04 15:04:29.662: WARN/dalvikvm(703): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-04 15:04:29.662: ERROR/AndroidRuntime(703): Uncaught handler: thread main exiting due to uncaught exception
04-04 15:04:29.702: ERROR/AndroidRuntime(703): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gormtech.zyx.RejseplanQuick/com.xxx.zyx.xxx.HelloAndroid}: android.database.sqlite.SQLiteException: unable to open database file


Any app can make a SQLiteDatabase without any special permissions.

I'm a little thrown by your code snippet because in my documents/SDK openOrCreateDatabase (on Context) takes three parameters: name, operating mode and factory. https://developer.android.com/reference/android/content/Context.html

It will be very revealing to see the output of your 'adb logcat'. Either run the adb application from a console, or bring up the LogCat window in Eclipse (it might help to switch to the DDMS Perspective). Run the app, get the failure and paste the later lines here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号