3

我像往常一样创建了一个数据库,但今天我收到了这个错误,我无法理解我的数据库有什么问题。

我试过用谷歌搜索,但这里没有答案我下面的代码用于创建数据库

error in sqlite : cannot open file at line 27701 of [8609a15dfa],
     public static final String ProvinceTable = "Provinces";
            public static final String COLUMN_PID = "PID";
            public static final String COLUMN_PName = "ProvinceNames";


     public void onCreate(SQLiteDatabase db )
       {
        try {
     db.execSQL(" CREATE TABLE " + ProvinceTable + " (" + COLUMN_PID + " INTEGER PRIMARY KEY  AUTOINCREMENT, " + COLUMN_PName + " TEXT)" );

    }

  public void onUpgrade(SQLiteDatabase db, int oldVersion , int newVesion) {

    Log.w(TAG, "Upgrading database from version " + oldVersion + "to"
            + newVesion + ", which will destroy all old data");
    db.execSQL("DROP TABLE IF EXISTS " + Cities_TABLE);

    onCreate(db);

      } 
    }

活动中

public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);
        setContentView(R.layout.insertstock);       



        DBAdapter db = new DBAdapter(this);



        db.open();

       Log.d("Adding", "Added");

       long id = db.insertRecord("name", "surname","***",  "address", "email", "number","province", "City", "payment", "delivery", "cardnumber", "username","password");            

       db.close();


 }
}

我在 logcat 中遇到了这个很长的错误。请帮我。

06-16 10:23:17.741: I/SqliteDatabaseCpp(5397): sqlite returned: error code = 14, msg = cannot open file at line 27701 of [8609a15dfa], db=/data/data/de.vogella.android.locationapi.simple/databases/DataInfo.db
06-16 10:23:17.741: I/SqliteDatabaseCpp(5397): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27701 - "" errno=2 path=/data/data/de.vogella.android.locationapi.simple/databases/DataInfo.db, db=/data/data/de.vogella.android.locationapi.simple/databases/DataInfo.db
06-16 10:23:17.741: E/SqliteDatabaseCpp(5397): sqlite3_open_v2("/data/data/de.vogella.android.locationapi.simple/databases/DataInfo.db", &handle, 6, NULL) failed
06-16 10:23:17.811: E/SQLiteDatabase(5397): Failed to open the database. closing it.
06-16 10:23:17.811: E/SQLiteDatabase(5397): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:983)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:956)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1021)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:734)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at de.vogella.android.locationapi.simple.DBAdapter.open(DBAdapter.java:125)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at de.vogella.android.locationapi.simple.InsertStock.onCreate(InsertStock.java:22)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.app.ActivityThread.access$1500(ActivityThread.java:122)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.os.Looper.loop(Looper.java:132)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at android.app.ActivityThread.main(ActivityThread.java:4025)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at java.lang.reflect.Method.invokeNative(Native Method)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at java.lang.reflect.Method.invoke(Method.java:491)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-16 10:23:17.811: E/SQLiteDatabase(5397):     at dalvik.system.NativeStart.main(Native Method)
06-16 10:23:17.831: D/AndroidRuntime(5397): Shutting down VM
06-16 10:23:17.831: W/dalvikvm(5397): threadid=1: thread exiting with uncaught exception (group=0x40014760)
06-16 10:23:17.871: E/AndroidRuntime(5397): FATAL EXCEPTION: main
06-16 10:23:17.871: E/AndroidRuntime(5397): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.vogella.android.locationapi.simple/de.vogella.android.locationapi.simple.InsertStock}: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.ActivityThread.access$1500(ActivityThread.java:122)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.os.Looper.loop(Looper.java:132)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.ActivityThread.main(ActivityThread.java:4025)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at java.lang.reflect.Method.invokeNative(Native Method)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at java.lang.reflect.Method.invoke(Method.java:491)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at dalvik.system.NativeStart.main(Native Method)
06-16 10:23:17.871: E/AndroidRuntime(5397): Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:983)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:956)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1021)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:734)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at de.vogella.android.locationapi.simple.DBAdapter.open(DBAdapter.java:125)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at de.vogella.android.locationapi.simple.InsertStock.onCreate(InsertStock.java:22)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
06-16 10:23:17.871: E/AndroidRuntime(5397):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
06-16 10:23:17.871: E/AndroidRuntime(5397):     ... 11 more
4

0 回答 0