Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Data Persistence CRUD Operations with SQLite Closing the Database

And finally, close the database! :)

in the videos we were using close(database) quite a bit but here its not working for the challenge, I dont understand the difference between close(database) and database.close(). Are they not interchangeable?

/* Add your code here! 
 * Assume you already have a variable named 'database'.

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,840 Points

Hi Sharon,

The short answer: No, they aren't interchangeable.

close(database) is a method that was created during the videos, and it specific only to that file being used in the video (and you files if you are following along).

I'm not sure which video that method was created in, but you can see the it here at 1:55. It is a private method with the purpose of executing database.close() which is a method called on the instance of the database.

In the challenge, there is no close method, so the challenge has no idea what you are trying to do. All the Challenge knows is that you are trying to call a method that does not exist (in its scope). So, you need to call the instance method on the object using dot notation.

Hopefully that helps clear it up. :)

Keep Coding! :dizzy: