I have been following android tutorial on the internet about SQLite. I got a statement which I'm not sure about:
public HotOrNot open(){
ourHelper = new DbHelper(ourContext);
ourDatabase = ourHelper.getWritableDatabase();
return this;
}
What does return this
mean in this method ? is it the current object or context ? thanks
return this
returns the current object instance. I don't know what HotOrNot
class is, but it's clear that this method is defined in that class. In the method, member variable ourHelper
is initialised with a new database helper and member variable ourDatabase
is assigned a writable database object from that helper - after which the instance of the class is returned - most likely, so that the calls could be chained, e.g.
new HotOrNot(myContext).open().runQuery("some query text")
See the Java language specifications for more information on this
keyword.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With