java - this.openOrCreateDatabase() 和 SQLiteDatabase.openOrCreateDatabase() 之间的区别
问题描述
当我遇到这个时,我正在尝试使用 android 创建一个 sqlite 数据库。
有2种方法this.openOrCreateDatabase()
和SQLiteDatabase.openOrCreateDatabase()
这两者有什么区别,应该使用哪一个
解决方案
this
将为您当前定义的类调用实例化对象上的方法。
SQLiteDatabase.openOrCreateDatabase()
将调用SQLiteDatabase
类中定义的静态方法。
public class YourObject {
//constructor
public void openOrCreateDatabase() {
//do something special
}
public void methodYouAreWriting() {
this.openOrCreateDatabase() //do something special - interacts with YourObject::openOrCreateDatabase
}
public void methodYouAreWritingToOpenSQLiteDatabase() {
SQLiteDatabase.openOrCreateDatabase() // Interacts with SQLiteDatabase class.
}
推荐阅读
- python-3.x - 如何在python中删除重复的“id”列值
- spring - Spring集成建模问题
- python - 从python中提取数据到excel
- arrays - 初始化 Array 之前使用的 Swift 变量
- java - 如何预编译 MVEL 规则?
- javascript - 如果 getElementById 未复制到 querySelectorAll 值,则输入值
- c# - 重构 Angular 服务以调用函数应用程序而不是 WebApi
- amazon-web-services - CloudFront 分发域状态 301 在自定义域上重定向
- flutter - 在颤动中需要这种堆叠的条形图
- ruby-on-rails - 建立另一个 ActiveRecord::Base 连接的后果是什么?旧连接会发生什么?