failed to read row 0,column -1

后端 未结 4 1719
天命终不由人
天命终不由人 2021-02-18 15:53

I am trying to copy a database that I made with SQLite manager, in which I did:

CREATE TABLE \"android_metadata\" (\"locale\" TEXT DEFAULT \'en_US\')
         


        
4条回答
  •  不知归路
    2021-02-18 16:21

    Another Scenario when this can happen:
    You are deleting rows from the cursor while the cursor is still in use.

    E.g pseudo-coden where it could happen:

    while(cursor.moveToNext()){
    
      readCursor(cursor);
    
      deleteRowFromCursor(cursor);
    
    }  
    

    Solution:

    Keep list of rows you want to delete; build a batch delete sql statement; execute the statment out side of the while loop ( when you are done with using the cursor anymore or after you close it).

    while(cursor.moveToNext()){
    
      readCursor(cursor);
    
      queueRowForDelete(cursor);
    
    } 
    
    deleteQueuedRows(queuedRowsList);
    

提交回复
热议问题