Spring 2022 MAI203 – Tech Bots w/ MIT AI2 Computer Storage and Cloud Storage Important Information 1/3 ○ ○ Prerequisite: Completion of MAI-101. ○ Class Times: Classes are held 5-7pm PT (7-9pm CT, 8-10pm ET). Each class consists of a theory section where concepts are introduced, as well as a lab portion where an instructor leads students through a hands-on exercise. ○ Office Hours: Office hours are held 6-7pm PT on Mondays and Wednesdays. All students are urged to attend for assistance in finishing homework projects. ○ ○ Zoom Link: All classes and office hour sessions use the same Class Dates: We have 8 instructor-led classes on Fridays, starting from Jan. 21 through Mar. 11. The exact class dates are: 1/21, 1/28, 2/4, 2/11, 2/18, 2/25, 3/4 and 3/11. Student ID: You will be assigned with a Student ID. If you have one from previous classes, the ID will remains the same. If you don’t have one. Email me: mit_ai2_bootcamp@outlook.com Dr. R. Feng 2 Your student ID ○ Student ID: 2S73 ○ Zoom Name: First Name - Student Id. For example: Tony-2S73 ○ Discord: Same as Zoom nickname. ○ Google account = MIT App Inventor Account Dr. R. Feng 3 Important Information 2/3 ○ Discord Server: Outside of class, students are encouraged to communicate with fellow classmates and instructors via Discord. Remember to change your nickname as First name + SID, e.g. David-2S43. In this group, we will post information, answer questions, and collaborate on problems. ○ Master Document: Links to ppt slides, class video, solution to in-class labs, homework assignments, solutions to homework, and all others are in the MASTER DOCUMENT. ○ Class Materials: Video recordings, PPT slides, submission links, and homework/lab solutions will be posted in a “Master Document." This document will be pinned in the Discord server for easy access. ○ Homework: Each class comes with a homework assignment. Students have 5 days to complete and submit their work. Solutions will be distributed the day after the assignment is due. Remember, completing homework is the most component to your learning! Late submissions will be accepted for partial credit. No excuses are accepted for missing submissions. Dr. R. Feng 4 Important Information 3/3 ○ Required Equipment: In addition to your PC (Windows/Mac),you must have an Android mobile device. The iOS will not work! Prior to our first class, you must install MIT App Inventor on your Android mobile device; installation instructions are available at https://appinventor.mit.edu/explore/ai2/setup-device-wifi. ○ Check Compatibility: Most of the popular Android devices are compatible to our bots. You are required to ensure the compatibility by following the instruction with the link https://appinventor.mit.edu/explore/aicompatible-devices. Dr. R. Feng 5 Advices on How to Study Well ○ Be present on time in the class. ○ Following the instructor, and repeat the in-class labs on your own PC and smart mobile device ○ Review the ppt slides (and the video if needed) after class ○ Participate in office hour sessions if you have not submitted your homework ○ Actively discuss in classes, office hour sessions, and the Discord group. ○ Submit homework assignments. Dr. R. Feng 6 Instructors: ○ Dr. Meng ○ Dr. Feng TAs: ○ TBD About Us Meet our team here Dr. R. Feng 7 https://appathon.appinventor.mit.edu/ Let us work together to take you to the winning stages. Dr. R. Feng Hackathons Dr. R. Feng https://gallery.appinventor.mit.edu/?galleryid=ac3e3f9c-d650-47bb-8f8c-3231e5bc83a0 11 Dr. R. Feng Dr. R. Feng Why do we need storage? Cloud Storage CPU Memory Random Access Memory Dr. R. Feng Why do we need storage? Storage Dr. R. Feng Why do we need storage? - Information such as variables are temporary When the app is restarted, the memory is cleared and you lose information. File Storage: - Allows you to read/write text data from a file. Applications: event logging, exporting data, etc More permanent form of storage → will stay on your device until the file is deleted Dr. R. Feng File Manipulation Functions Adds the input text to the end of the designated file. Ex. File1.txt contains “oldtext” File1.AppendToFile(“newtext”, “File1.txt”) → File1.txt contains “oldtextnewtext” Deletes the designated file * You cannot do this with protected files Retrieves the text from the designated file Saves input text to a file If the file already exists, it will overwrite the contents of the file Dr. R. Feng File Events Triggers after the file has successfully saved. Means that the contents have already been written and confirms that there were no errors in the writing process. Triggers after text is successfully retrieved from the file. Only way to confirm a file can be read and to access the text. Dr. R. Feng External Files Files located elsewhere on your device. Use slashes to denote the file’s directory, and use a leading slash to tell your app to look outside of its private folder Ex. Will look in storage → Download → filename.txt Will look in storage → app private folder → Download → filename.txt Dr. R. Feng App Data Files Files located in sdcard (or phone internal storage) → AppInventor → data Access files by using the file’s name ⇒ If you are on the companion, will read from AppInventor/data ⇒ If as a packaged app (.apk), will read from the app’s private directory This means that other programs will not be able to access it! Dr. R. Feng Asset Files Packaged with the application (.apk file) Use “//” at the beginning of the fileName variable to tell the code to look in the app’s asset files Since asset files are packaged with the app, you cannot modify or delete them Dr. R. Feng Overview: Reading from files 1. “Filename.txt” a. Reads from the app’s private directory b. Not accessible by other apps c. Use for data that you need to save but is not needed elsewhere 2. “/Filename.txt” a. Reads from your device’s sdcard or internal storage b. Can be accessed by other apps c. Use for exporting data from your app 3. “//Filename.txt” a. Reads from app’s asset files b. Cannot be deleted or modified c. Use for storing information the app needs on startup Dr. R. Feng CloudDB: Online Storage Allows you to store data on an Internet connected server (Redis software) Users of the app can share data with each other → All users will share the same server! CloudDB stores data based on a tag system, much like a dictionary Tag, Data Dr. R. Feng CloudDB Methods Appends the designated item to the end of the list under the given tag. * Multiple users can append at the same time Clears the data under the given tag Returns true/false based on whether the app is connected to CloudDB Retrieves a list of tags from CloudDB Dr. R. Feng CloudDB Methods Cont. Retrieves the value at the given tag Returns a specific value if the tag is not found Removes the first item of the list located at the specific tag Stores the value at the specified tag. Dr. R. Feng CloudDB Events Specifies actions if an error is encountered. Specifies actions when data on CloudDB is changed Triggered by the function RemoveFirstFromList Triggered when a value is successfully retrieved Triggers when the tag list is successfully retrieved Dr. R. Feng List View, Spinner, and ListPicker Dr. R. Feng Walkthrough Project # 1 Implement an app to create a file, append text to the file, and then delete the file. Pay attention to the events the file component has. Understand event invocations can be available in software objects or components, in additions to human beings. Dr. R. Feng Walkthrough Project # 2 Implment an app to store data in the cloud using CloudDB, retrieve data from the CloudDB, and display the data with ListView, Spinner, or ListPicker. Dr. R. Feng Dr. R. Feng Homework Assignment ● Open the in-class lab with the following link. Instead using Spinner, apply ListPicker and ListView to add two functions of (1) selecting a tag from the list, and (2) display the value with a notifier message. Hint: The process is similar to the Spinner process. ● https://gallery.appinventor.mit.edu/?galleryid=38ba2928-d9a6-4c54-ace137446c4b2dc7 Dr. R. Feng ArcGen Technologies, LLC Thank You Dr. Y. Meng +1 469 999 7985 Mit_ai2_bootcamp@outlook.com http://www.aysi.org /