无法在第27805行打开文件

时间:2015-09-04 20:52:59

标签: java android sqlite

我有一个很大的问题我无法理解,基本上在从数据库中读取大约130次之后访问我的android数据库时,它会将其抛入logcat并且活动结束。数据库正在完全读取,直到这一点,并且每次都无法看到它在此时失败的原因。 09-04 16:45:31.754: E/SQLiteLog(4213): (14) cannot open file at line 27805 of [9491ba7d73] 09-04 16:45:31.754: E/SQLiteLog(4213): (14) os_unix.c:27805: (24) open(/data/data/com.boltgames.dev.cricketone/databases) - 09-04 16:45:31.758: E/SQLiteLog(4213): (14) cannot open file at line 30046 of [9491ba7d73] 09-04 16:45:31.758: E/SQLiteLog(4213): (14) os_unix.c:30046: (24) open(/data/data/com.boltgames.dev.cricketone/databases/Student.db-journal) - 09-04 16:45:31.758: E/SQLiteLog(4213): (14) cannot open file at line 30046 of [9491ba7d73] 09-04 16:45:31.758: E/SQLiteLog(4213): (14) os_unix.c:30046: (24) open(/data/data/com.boltgames.dev.cricketone/databases/Student.db-journal) - 09-04 16:45:31.758: E/SQLiteLog(4213): (14) statement aborts at 37: [SELECT DISTINCT _id, NAME, SURNAME, AGE, STAMINA, FITNESS, BOWLINGSKILL, BATTINGSKILL, OVERS, MAIDENS, BWLRUNS, WICKETS, ECONOMY, STRIKERATE, INNS, NOTOUT, BATRUNS, FIFTY, HUNDRED, FOU 09-04 16:45:31.759: E/SQLiteQuery(4213): exception: unable to open database file (code 14); query: SELECT DISTINCT _id, NAME, SURNAME, AGE, STAMINA, FITNESS, BOWLINGSKILL, BATTINGSKILL, OVERS, MAIDENS, BWLRUNS, WICKETS, ECONOMY, STRIKERATE, INNS, NOTOUT, BATRUNS, FIFTY, HUNDRED, FOURS, SIXES, DUCKS, CURBALLS, CURRUNS, CURFOURS, CURSIXES FROM Langley 09-04 16:45:31.759: D/AndroidRuntime(4213): Shutting down VM 09-04 16:45:31.760: E/AndroidRuntime(4213): FATAL EXCEPTION: main 09-04 16:45:31.760: E/AndroidRuntime(4213): Process: com.boltgames.dev.cricketone, PID: 4213 09-04 16:45:31.760: E/AndroidRuntime(4213): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:845) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:144) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:197) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:237) 09-04 16:45:31.760: E/AndroidRuntime(4213): at com.boltgames.dev.cricketlife.DatabaseHelper.getAllRows(DatabaseHelper.java:124) 09-04 16:45:31.760: E/AndroidRuntime(4213): at com.boltgames.dev.cricketlife.Play.SetData(Play.java:149) 09-04 16:45:31.760: E/AndroidRuntime(4213): at com.boltgames.dev.cricketlife.Play.SetPlayers(Play.java:134) 09-04 16:45:31.760: E/AndroidRuntime(4213): at com.boltgames.dev.cricketlife.Play.PlayOneRun(Play.java:277) 09-04 16:45:31.760: E/AndroidRuntime(4213): at com.boltgames.dev.cricketlife.Play$1.onClick(Play.java:249) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.view.View.performClick(View.java:4780) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.view.View$PerformClick.run(View.java:19866) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.os.Handler.handleCallback(Handler.java:739) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.os.Handler.dispatchMessage(Handler.java:95) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.os.Looper.loop(Looper.java:135) 09-04 16:45:31.760: E/AndroidRuntime(4213): at android.app.ActivityThread.main(ActivityThread.java:5254) 09-04 16:45:31.760: E/AndroidRuntime(4213): at java.lang.reflect.Method.invoke(Native Method) 09-04 16:45:31.760: E/AndroidRuntime(4213): at java.lang.reflect.Method.invoke(Method.java:372) 09-04 16:45:31.760: E/AndroidRuntime(4213): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 09-04 16:45:31.760: E/AndroidRuntime(4213): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

这是我对数据库的访问代码

cursor = mydb.getAllRows(gamemanager.hometeam);
    cursor.moveToFirst();
    startManagingCursor(cursor);
    String[] fromfieldnames = new String[]{DatabaseHelper.COL_2, DatabaseHelper.COL_3,
            DatabaseHelper.COL_23, DatabaseHelper.COL_24};
    int[] toviewids = new int[]{R.id.scorecplayer, R.id.scorecsur, R.id.scorecballs, R.id.scorecruns};
    mycursoradaptor = new SimpleCursorAdapter(this, R.layout.scorecardbat,
            cursor, fromfieldnames, toviewids);
    batting.setAdapter(mycursoradaptor);
    totruns.setText(Long.toString(totalruns));
    ballComplete = true;
    oneballnorun.setVisibility(View.VISIBLE);

请帮助:(

微米。

编辑: - 添加了数据库脚本代码

SQLiteDatabase db = this.getWritableDatabase();
    // Return all data in database
    String where = null;
    cursor = db.query(true, teamname, ALL_KEYS, where, null, null, null, null, null);
    Log.i("Success2", "Data is accessed");
    if (cursor != null){
        Log.i("Cursor3", cursor.toString());
        cursor.moveToFirst();

    }
    if(cursor == null){
        Log.i("Error!!!", "No Data!");
    }
    return cursor;

1 个答案:

答案 0 :(得分:0)

mydb.cursor.close();
    Log.i("Success1", "Access Started");
    try {
        cursor = mydb.getAllRows(gamemanager.hometeam);
    }catch (Throwable ex) {
        Log.i("Error", "Maybe retrying i dont know");
    }
    Log.i("Success!4", "Cursor is Active!" );
    startManagingCursor(cursor);
    Log.i("Success!5", "Cursor is being managed");
    String[] fromfieldnames = new String[]{DatabaseHelper.COL_2, DatabaseHelper.COL_3,
            DatabaseHelper.COL_23, DatabaseHelper.COL_24};
    Log.i("Success6", "Stage1");
    int[] toviewids = new int[]{R.id.scorecplayer, R.id.scorecsur, R.id.scorecballs, R.id.scorecruns};
    Log.i("Success7", "Stage2");
    mycursoradaptor = new SimpleCursorAdapter(this, R.layout.scorecardbat,
            cursor, fromfieldnames, toviewids);
    Log.i("Success8", "Stage3");
    batting.setAdapter(mycursoradaptor);
    Log.i("Success9", "Stage4");