Android Native Databases as Persistent Storage

Margaret Kozak Polk · 2024

This chapter addresses the SQLite database as a second form of persistent storage available to apps. An overview of databases is provided keeping in mind the reader who may not be proficient or experienced with databases. The logical organization of a database is explained in brief, and databases used in the chapter are constrained to a single table, so as to not intimidate the reader with no prior database experience. Step-by-step Java instructions and accompanying explanations are provided for creating a database, creating a table within a database, adding records to a database table, removing records from a table, and retrieving information from a database table. The advantages of using a Java “try/catch” structure and the encouragement to do so are presented. The physical location of a database file within the nonvolatile memory area allotted to an app is explored in detail using the Device Explorer. A more advanced topic related to assigning database values to the entries of a “ Spinner ” widget is furnished. The chapter concludes with exercises, some of which build on and enhance exercises introduced in previous chapters, to provide practice with the topics covered in this chapter.

Read the paper · More papers on PaperTik