It's written to this way

Month: February 2018

Lesson 10: Storing data using SQLite (10.1A: SQLite Database)

Task 0. Download and run the starter code

Task 1. Extend SQLiteOpenHelper to create and populate a database

1.1 Create a skeleton WordListOpenHelper class

1.2. Add database constants to WordListOpenHelper

1.3. Build the SQL query and code to create the database

1.4 Create the database in onCreate of the MainActivity

1.5 Add data to the database

Task 2. Create a data model for a single word

2.1. Create a data model for your word data

Task 3. Implement the query() method in WordListOpenHelper

3.1. Implement the query() method

3.2. The onUpgrade method

Task 4. Display data in the RecyclerView

4.1. Update WordListAdapter to display WordItems

Task 5. Add new words to the database

5.1. Write the insert() method

5.2. Get the word to insert from the user and update the database

5.3. Implement getItemCount()

Task 6. Delete words from the database

6.1. Write the delete() method

6.2. Add a click handler to DELETE button

Task 7. Update words in the database

7.1. Write the update() method

7.2. Add a click listener to the EDIT button

7.3. Add updating to onActivityResult

7.4. Design and error considerations

  • The methods you wrote to add, update and delete entries in the database all assume that their input is valid. This is acceptable for sample code because the purpose of this sample code is to teach you the basic functionality of a SQLite database, and so not every edge case is considered, not every value is tested, and everybody is assumed to be well behaved. If this were a production app, you would have greater security considerations, and content would need to be tested for validity until you know it is not malicious.
  • In a production app, you must catch specific exceptions and handle them appropriately.
  • You tested the correct functioning of the app by running it. For a production app with real data, you will need more thorough testing, for example, using unit and interface testing.
  • For this practical, you created the the database schema/tables from the SQLiteOpenHelper class. This is sufficient for a simple example, like this one. For a more complex app, it is a better practice to separate the schema definitions from the rest of the code in a helper class that cannot be instantiated. You will learn how to do that in the chapter on content providers.
  • As mentioned above, some database operations can be lengthy and should be done on a background thread. Use AsyncTask for operations that take a long time. Use loaders to load large amounts of data.

Lesson 9: Preferences and Settings (9.2: Adding Settings to an App)

Task 1: Add a switch setting to an app

1.1 Create the project and add the xml directory and resource file

1.2 Add the XML preference and attributes for the setting

1.3 Add an activity for settings and a fragment for a specific setting

 

1.4 Connect the Settings menu item to the settings activity

1.5 Save the default values in shared preferences

1.6 Read the changed settings value from shared preferences

Task 2: Using the Settings Activity template

2.1 Explore the Settings Activity template

2.2 Add the Settings menu item and connect it to the activity

 

2.3 Customize the settings provided by the template

 

2.4 Add code to set the default values for the settings

2.5 Add code to read values for the settings

Lesson 8: Triggering, scheduling and optimizing background tasks (8.2: Alarm Manager)

Task 1. Set up the Stand Up! project and views

1.1 Create the Stand Up! project layout

1.2 Set up the setOnCheckedChangeListener() method

Task 2. Set up the notification

2.1 Create the notification

Task 3. Create the repeating alarm

3.1 Set up the broadcast pending intent

3.2 Set the repeating alarm

3.3 Create the Broadcast Receiver

3.5 Check the state of the alarm

 

Lesson 8: Triggering, scheduling and optimizing background tasks (8.1: Notifications)

Task 1. Create a basic notification

1.1 Create the project

1.2 Build your first notification

1.3 Add a content intent

1.4 Add priority and defaults to your notification

Task 2. Update and cancel your notification

2.2 Implement the cancel and update notification methods

2.3 Toggle the button state

Task 3. Add notification actions

3.1 Implement the “Learn More” action

3.2 Implement the “Update” action

 

Lesson 7: Background Tasks (7.3: Broadcast Receivers)

Task 1. Set up the PowerReceiver Project

1.1 Create the Project

1.2 Register your Receiver for system broadcasts

1.3 Implement onReceive() in your BroadcastReceiver

1.4 Restrict your Broadcast Receiver

Task 2. Send and Receive a Custom Broadcast

2.1 Define your custom Broadcast Action string

2.2 Add a “Send Custom Broadcast” Button

2.3 Implement sendCustomBroadcast()

2.4 Register your Custom Broadcast

2.5 Respond to the Custom Broadcast

Lesson 7: Background Tasks (7.2: Connect to the Internet with AsyncTask and AsyncTaskLoader)

Task 1. Explore the Books API

1.1 Send a Books API Request

1.2 Analyze the Books API Response

Task 2. Create the “Who Wrote It?” App

2.1 Create the project and user interface

2.2 Set up the Main Activity

2.3 Create an empty AsyncTask

2.4 Create the NetworkUtils class and build the URI

2.5 Make the Request

2.6 Add the Internet permissions

2.7 Parse the JSON string

Task 3. Implement UI Best Practices

3.1 Hide the Keyboard and Update the TextView

3.2 Manage the network state and the empty search field case

Task 4. Migrate to AsyncTaskLoader

4.1 Create an AsyncTaskLoader

4.2 Modify MainActivity

 

© 2024 Dwimagita's blog

Theme by Anders NorenUp ↑