由于某种原因,我想在应用程序中删除我的 sqlite db:
this.deleteDatabase(contentProvider.getDatabaseName());
之后我想重新创建我的数据库文件。
我在文档中读到:
onCreate is called for all registered content providers on the application main thread at application launch time.
这就是我在启动时在 OnCreate 中创建数据库的方法:
@Override
public boolean onCreate() {
try {
contentProviderHelp = new ContentProviderHelp();
userInfoTable = new UserInfoTable(contentProviderHelp);
employeeInfoTable = new EmployeeInfoTable(contentProviderHelp);
productsTable = new ProductsTable(contentProviderHelp);
db = new DbMetadata(userInfoTable, employeeInfoTable, productsTable);
ddlHelp = new DDLHelper(db);
matcher = new UriMatch(userInfoTable, employeeInfoTable, productsTable, new UriMatcher(UriMatcher.NO_MATCH));
dbHelp = new DatabaseHelper(getContext(), DATABASE_NAME, DATABASE_VERSION, ddlHelp);
projectionMaps = new ProjectionHelper(db);
return true;
} catch (Exception e) {
return false;
}
}
你能帮我在删除数据库文件后如何重新创建 ContentProvider 吗?