Book Image

Expert Delphi - Second Edition

By : Marco Cantù, Paweł Głowacki
Book Image

Expert Delphi - Second Edition

By: Marco Cantù, Paweł Głowacki

Overview of this book

Master Delphi, the most powerful Object Pascal IDE and versatile component library for cross-platform native app development, by harnessing its capabilities for building natively compiled, blazingly fast apps for all major platforms, including Android, iOS, Windows, Mac, and Linux. Expert Delphi begins with a quick overview of Delphi, helping you get acquainted with the IDE and the Object Pascal language. The book then quickly progresses to more advanced concepts, followed by the architecture of applications and the FireMonkey library, guiding you through building server-side services, parallel programming, and database access. Toward the end, you’ll learn how to integrate your app with various web services and deploy them effectively. By the end of this book, you’ll be adept at building powerful, cross-platform, native apps for iOS, Android, Windows, and macOS—all from a single code base.
Table of Contents (21 chapters)
Free Chapter
1
Part 1: Building Blocks
6
Part 2: Going Mobile
12
Part 3: From Data to Services
19
Index

Working with files and streams

Almost every app needs to persist data. Imagine that you have just downloaded an app and worked with it for a while. The next time you open it, you would like to see that it has remembered what you have done so far. An app can store its data in the cloud, in an embedded database, or in a file. This last option is the easiest to use, and so it’s the one we want to start from.

A local file can store information in different formats. It could be a binary file, which is just an array of bytes that is left to an app to make sense of, or it could be a text file. Your app can store information in plain text or it can use file formats such as JSON or XML to make it easier to process structured information, even if saved as text.

Imagine that you would like to write a small mobile app to keep track of your favorite locations on the internet. To keep it simple, it could be just a list of favorite items made up of two strings: a URL and a caption. Let...