解决方法
公共同步sqliteDatabase getReadableDatabase()
自:API级别1
Create and/or open a database. This will be the same object returned
by getWritableDatabase() unless some problem,such as a full disk,
requires the database to be opened read-only. In that case,a
read-only database object will be returned. If the problem is fixed,a
future call to getWritableDatabase() may succeed,in which case the
read-only database object will be closed and the read/write object
will be returned in the future.
与getWritableDatabase()一样,此方法可能需要很长时间才能返回,因此您不应从应用程序主线程(包括ContentProvider.onCreate())调用它.
返回
a database object valid until getWritableDatabase() or close() is called.
公共同步sqliteDatabase getWritableDatabase()
自:API级别1
Create and/or open a database that will be used for reading and
writing. The first time this is called,the database will be opened
and onCreate(sqliteDatabase),onUpgrade(sqliteDatabase,int,int)
and/or onOpen(sqliteDatabase) will be called.Once opened successfully,the database is cached,so you can call this
method every time you need to write to the database. (Make sure to
call close() when you no longer need the database.) Errors such as bad
permissions or a full disk may cause this method to fail,but future
attempts may succeed if the problem is fixed.
数据库升级可能需要很长时间,您不应该从应用程序主线程调用此方法,包括从ContentProvider.onCreate().
返回
a read/write database object valid until close() is called