KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an application that runs an activity with a service in a separate process that is started and bound to the activity. The service contains a handler that posts a runnable to be run after a delay. I want each component to log to the database, so I implemented a content provider that deals with database access and I call it from the service or activity via extended AsyncTask sub-classes. This all works beautifully on the emulator, but when I run it in debug on my phone I get a sporadic database locked error on my database writing: UPDATE I made some changes to my database handling and the error has changed slightly. ERROR/Database(15235): Error inserting MY_MESSAGE ERROR/Database(15235): android.database.sqlite.SQLiteException: error code 5: database is locked ERROR/Database(15235): at android.database.sqlite.SQLiteStatement.native_execute(Native Method) ERROR/Database(15235): at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61) ERROR/Database(15235): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1591) ERROR/Database(15235): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1435) ERROR/Database(15235): at mypackagename.DatabaseHelper.insertLogging(DatabaseHelper.java:190) ERROR/Database(15235): at mypackagename.ContentProvider.insert(ContentProvider.java:139) ERROR/Database(15235): at android.content.ContentProvider$Transport.insert(ContentProvider.java:198) ERROR/Database(15235): at android.content.ContentResolver.insert(ContentResolver.java:604) ERROR/Database(15235): at mypackagename.Activity$LogToDatabase.doInBackground(Activity.java:642) ERROR/Database(15235): at mypackagename.Activity$LogToDatabase.doInBackground(Activity.java:1) ERROR/Database(15235): at android.os.AsyncTask$2.call(AsyncTask.java:185) ERROR/Database(15235): at java.util.concurrent.FutureTask$Syn
Tags (comma-separated)
Save Edits
Cancel