O'Reilly logo

Creating Apps in Kivy by Dusty Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Kivy Storage

So far, every time you run your weather app, it asks you to search for a location. It would be much more convenient if it could store your last location and render it by default.

Kivy is a Python library, which means you have access to the full gamut of Python storage modules. You could use basic file I/O, compression, encryption, pickling, JSON, SQLite3, an external SQL or NoSQL database, or any number of online storage services.

Depending on the data being stored, these are certainly useful tools worth checking out. However, Kivy also provides a simple but powerful key/value storage API for storing local data. Its primary advantage is that because Kivy is aware of the module, it works across the wide variety of platforms that Kivy uses without having to take into account filesystem structure or other differences between various operating systems.

Maintaining a List of Locations

Before looking at storing the locations, update the app to have a Locations tab. This involves nothing you haven’t studied before, so you may want to think of it as an exercise. I’ll try to keep this section brief so as not to bore you with knowledge you already have. If you want to skip this section, you can download the example code from O’Reilly and proceed to the next section.

Here’s what you need to do, step by step. As mentioned, there is some example code for the more complicated steps. Note in advance that the ListView of locations behaves exactly like the ListView for search ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required