{"id":21144744,"url":"https://github.com/vdbe/app-dev-notes","last_synced_at":"2026-02-28T05:44:16.846Z","repository":{"id":118776144,"uuid":"497264601","full_name":"vdbe/app-dev-notes","owner":"vdbe","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-31T23:43:50.000Z","size":507,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T08:55:59.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vdbe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-28T08:54:05.000Z","updated_at":"2022-05-28T08:54:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c09e70a-f33e-4a9e-a429-7539285a8796","html_url":"https://github.com/vdbe/app-dev-notes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vdbe/app-dev-notes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdbe%2Fapp-dev-notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdbe%2Fapp-dev-notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdbe%2Fapp-dev-notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdbe%2Fapp-dev-notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vdbe","download_url":"https://codeload.github.com/vdbe/app-dev-notes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdbe%2Fapp-dev-notes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278916435,"owners_count":26068090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T08:22:00.042Z","updated_at":"2025-10-08T08:56:00.014Z","avatar_url":"https://github.com/vdbe.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Index table Test123\n- [Index table](#index-table)\n- [Intro](#intro)\n  - [Security](#security)\n  - [Aplication structure](#aplication-structure)\n    - [Android manifest](#android-manifest)\n      - [Content](#content)\n    - [Application code](#application-code)\n      - [Android components](#android-components)\n        - [Activities](#activities)\n          - [Need a god title here](#need-a-god-title-here)\n        - [Services](#services)\n        - [Content provider](#content-provider)\n        - [Broadcast receiver](#broadcast-receiver)\n  - [Resources](#resources)\n    - [Layouts](#layouts)\n      - [UI Compontents](#ui-compontents)\n      - [Layout or container views](#layout-or-container-views)\n      - [XML attributes](#xml-attributes)\n      - [Layouts in java](#layouts-in-java)\n  - [Gradle](#gradle)\n- [Input Events](#input-events)\n  - [Event Listeneres](#event-listeneres)\n  - [Event Handlers](#event-handlers)\n  - [Input controls](#input-controls)\n- [Intent](#intent)\n  - [Use cases](#use-cases)\n  - [Explicit intents](#explicit-intents)\n  - [Implicit intents](#implicit-intents)\n    - [Starting Activity](#starting-activity)\n      - [Intent](#intent-1)\n      - [Results](#results)\n      - [Passing data](#passing-data)\n    - [Intent Filters](#intent-filters)\n- [User interface](#user-interface)\n  - [Views](#views)\n    - [View attributes](#view-attributes)\n  - [View Groups](#view-groups)\n  - [Layouts](#layouts-1)\n    - [FrameLayout](#framelayout)\n      - [Frame](#frame)\n      - [Linear](#linear)\n      - [Grid](#grid)\n      - [Relative](#relative)\n      - [Constraint](#constraint)\n  - [Constraints](#constraints)\n  - [Responsive Design](#responsive-design)\n  - [Localization](#localization)\n- [RecyclerView](#recyclerview)\n  - [How it works](#how-it-works)\n  - [Optimizations](#optimizations)\n  - [Layoutmanager](#layoutmanager)\n  - [Viewholder](#viewholder)\n  - [Recyclerview Items](#recyclerview-items)\n  - [Adapter](#adapter)\n  - [Listener interface](#listener-interface)\n- [Networking \u0026 Threading](#networking--threading)\n  - [URI](#uri)\n- [Storing Data: Database](#storing-data-database)\n  - [Storing steps](#storing-steps)\n  - [Database contract](#database-contract)\n  - [Database creation](#database-creation)\n- [Prefrences](#prefrences)\n  - [OnSavedInstanceState](#onsavedinstancestate)\n  - [SharedPrefrences](#sharedprefrences)\n      - [PreferenceFragment](#preferencefragment)\n  - [Database](#database)\n  - [File Storage](#file-storage)\n  - [Online storage](#online-storage)\n\n# Intro\n\n## Security\n\n- Multi-user Linux system\n- Each app\n    - Different user\n    - Unique uid with permssiosn for own app\n    - Own VM\n    - Own Linux Process\n    - Only access to components it requires (principle of least privilege)\n\n## Aplication structure\n\n### Android manifest\nIs en XML based file names 'AndroidManifest.xml'.  \nThis is used by Google Play to check app compatibility\n\n#### Content\n- Package (app) name\n- App Components (declerations)\n    - Activities\n    - Services\n    - Broadcast Receivers\n    - Content Providers\n- Permissions\n    - uses-permissions  \n        Device features rquired, like Internet or SMS\n- Hardware and software features needed\n    - uses-feature  \n        Hardware features required\n    - uses-sdk  \n        This will be overwritten by Grade\n        - minSDK: Minimum API version\n        - targetSDK: Minimum API version  \n            Latest version by default\n\n\n- Code for components\n- Resources\n- Grade build system\n\n\u003cdetails\u003e\n\u003csummary\u003e Example \u003c/summary\u003e\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.example.appdev\"\u003e\n\n    \u003cuses-feature android:name=\"android.hardware.camera.any\"\n                  android:required=\"true\" /\u003e\n    \u003cuses-sdk android:minSdkVersion=“21\"\n              android:targetSdkVersion=“31\" /\u003e\n    \u003cuses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" /\u003e\n    \u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n\n    \u003capplication\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n        android:networkSecurityConfig=\"@xml/network_security_config\"\n        android:theme=\"@style/Theme.AppDev\"\u003e\n        \u003cactivity\n            android:name=\".SettingsActivity\"\n            android:exported=\"false\" /\u003e\n        \u003cactivity\n            android:name=\".EaterActivity\"\n            android:exported=\"false\" /\u003e\n        \u003cactivity\n            android:name=\".Factory\"\n            android:exported=\"false\" /\u003e\n        \u003cactivity\n            android:name=\".MainActivity\"\n            android:exported=\"true\"\u003e\n            \u003cintent-filter\u003e\n                \u003caction android:name=\"android.intent.action.MAIN\" /\u003e\n\n                \u003ccategory android:name=\"android.intent.category.LAUNCHER\" /\u003e\n            \u003c/intent-filter\u003e\n        \u003c/activity\u003e\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n\u003c/details\u003e\n\n### Application code\n\n#### Android components\n##### Activities\n- Entry point for interaction with the user\n- Single screen with a user interface\n- Work together for cohesive user experience\n- Independent of eacht other\n\n###### Need a god title here\n- Fundamental building block\n- Almost all interact with the users\n- Activity class creates window\n- Lifecycle translates into a lot of methods in the activity\n\n\u003cimg src=\"./assets/activity-structure.png\" width=\"420\"/\u003e\n\n```java\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n    }\n}\n```\n- onCreate()\n    - Must be implemented\n    - Basic application startup logic\n    - Can restore previously saved state\n- onStart()  \n    Makes activity visible to user\n- onResume()  \n    Intializes components that must occur every time the activity is restarted  \n    after being paused\n- onPause()  \n    Called first after user start leaving activity\n    - used to release resourcces no longer necessary\n    - Can stay in paused state until activity resume\n- onStop()  \n    Occurs when activity no longer visible to user\n    - Used to release resources not needed when activity not visible\n    - Perform CPU-intentsive shutdown operations\n- onDestroy()  \n    Called when activity destroyed\n    - Used to release resources not released yet\n\n##### Services\n- Entry point for keepign app running in background\n    - Long running operaitons\n    - Work for remote processes\n- No user interface  \n\n##### Content provider\n- Manges a shared set of data that can be stored\n    - File system\n    - SQLite database\n    - online\n    - ...\n- Lets other apps query or modify data\n\n##### Broadcast receiver\n- Enables the sytem to deliver events to an app outside the reuglar user flow\n- Allow app to respond to system-wide broadcast announcements\n- Many are system events\n    - Screen turned off\n    - Battery low\n    - Picture captured\n\n## Resources\n- Provided through xml files\n- Visual presentation of the app\n    - Images\n    - Styles\n    - Animations\n    - ...\n- Simple constants\n    - Colors\n    - Strings\n    - Booleans\n- Variety of devices\n    - Screen size/density/orientation\n- Handler through quoalifiers inthe dir names\n\n### Layouts\nDefined in XML\n\n\u003cdetails\u003e\n\u003csummary\u003e Example \u003c/summary\u003e\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    android:padding=\"16dp\"\n    tools:context=\"com.example.android.exampleapp.MainActivity\"\u003e\n\n    \u003cEditText\n        android:id=\"@+id/edit_text_name_input\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:background=\"@color/colorAccent\"\n        android:hint=\"Enter your name\"\n        android:padding=\"4dp\"\n        android:textSize=\"24sp\" /\u003e\n\n    \u003cTextView\n        android:id=\"@+id/text_view_name_display\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center\"\n        android:layout_marginTop=\"8dp\"\n        android:text=\"Your name appears here\"\n        android:textSize=\"30sp\" /\u003e\n\u003c/LinearLayout\u003e\n```\n\n\u003c/details\u003e\n\n#### UI Compontents\n| Class Name  | Description                                                 |\n|-------------|-------------------------------------------------------------|\n| TextView    | Creates text on the screen; generally non interactive text. |\n| EditText    | Creates a text input on the screen                          |\n| ImageView   | Creates an image on the screen                              |\n| Button      | Creates a button on the screen                              |\n| Chronometer | Creates a simple timer on screen                            |\n\n#### Layout or container views\n| Class Name       | Description                                                                                                               |\n|------------------|---------------------------------------------------------------------------------------------------------------------------|\n| LinearLayout     | Displays views in a single column or row.                                                                                 |\n| RelativeLayout   | Displays views positioned relative to each other and htis view.                                                          |\n| FrameLayout      | A ViewGroup meant to contains a single child view.                                                                        |\n| ScrollView       | A FrameLayout that is designed to let the user scroll through the content in the view.                                    |\n| ConstraintLayout | This is a newer viewgroup; it postions views in a flexible way. We'll be exploring constraintslayout later in the lesson. |\n| GridLayout       | A layout that places its children in a rectangular grid.                                                                  |\n\n#### XML attributes\n- Control the properties of a view\n- Determine how a biew looks and interacts\n- Examples: Text, Widh and height, Padding and Margin, Color\n\n#### Layouts in java\nLoading in the onCreate() method of the activity through setContentView()\n\n\u003cdetails\u003e\n\u003csummary\u003e Example \u003c/summary\u003e\n\n```java\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        // other code to setup the activity\n    }\n    // other code\n}\n```\n\u003c/details\u003e\n\n## Gradle\n- Open source build automation system  \n    Not only for android\n- Scription tool to build software in general  \n    Compile code, Link to libraries, Run tests, Create packages, ...\n- 3 steps\n    1. Initialization  \n        Set up environment for build\n    2. Configuration  \n        - Construct task graph\n        - Determine tasks to run and in which order\n    3. Execution  \n        Run the selected tasks\n- Build Type  \n    Debug, Release\n- Manifest Entries\n    Overrides value of the manifest: App Name, min API version, target API version\n\n\u003cimg src=\"./assets/gradle-structure.png\" width=\"250\"/\u003e\n\n# Input Events\n- Interaction between the user and the application\n- Extendable input\n\n## Event Listeneres\n- Interface in View vlass with one callback method\n- Called when a niew is triggered by user Interaction\n- Dependent on input controls\n- Examples\n    - OnClickListener -\u003e OnClick()\n    - OnLongClickListener -\u003e OnLongClick()\n    - OnTouchListener -\u003e OnTouch()\n\n## Event Handlers\n- Used for extension of a View\n- Define default even behavior\n- Examples:\n    - onKeyDown\n    - onTouchEvent\n    - dispatchTouchEvent\n\n## Input controls\n- Interactive components in the UI\n- Described in layout trhough XML element\n- Supports set of specific input events\n- Examples:\n    - Button\n    - CheckBox\n    - Spinner\n    - EditText\n\n# Intent\n- Don't call eachother directly\n    - Use messaging objects called intents\n- Let an app request tahn an action takes place\n    - start new activity\n    - Display Photo from gallery\n    - Make phone call\n- Contains also:\n    - Which component to deliver to\n    - Small amount of data\n        - Packaged as extras\n        - Primitive tuples\n\n## Use cases\n- Starting an activity\n- Starting a service (API lvl \u003c= 20)\n- Delivering a broadcast\n\n## Explicit intents\n- Specify which component will satisfy intent\n    - App's package name\n    - Class name\n- Typically used to start component in own app\n\n## Implicit intents\n- Don't specify component\n- No receiver specified\n- Declare general action to perform\n    - Other apps can respond to this\n    - System looks through intent filters of all apps to:\n        - Start activityy that can respond to the action\n        - Let user choose an appt ot respond to the action\n    - Data can be packaged\n\n\n### Starting Activity\n#### Intent\n- Describes activity to start\n- Carries necessary data\n- startActivity(Intent)\n\n#### Results\n- Calling activity receives separate intent object\n- Can handle object in specific callback function\n- startActivityForResult(Intent)\n\n#### Passing data\n- Data elements can be put into the intent envelope\n- Data elements are called extras (Primitives stored as key-value pairs)\n    - `putExtra()`: Give to intent\n    - `get\u003cType\u003eExtra()`: get out of intent\n\n### Intent Filters\n- More than one intent filter can be declared for an activity\n    - Activity should respond differently to each filter\n- Intent filter can contain 3 elements  \n    1. \\\u003caction\u003e\n        - Intent action accepted, in name attribute\n        - Must be a literal string value of an action\n    2. \\\u003cdata\u003e\n        - Type of data accepted\n    3. \\\u003ccategory\u003e\n        - Intent category accpeted, in name attribute\n        - CATEGORY_DEFAULT must be included\n    - A filter  can contain more than one instace of these elements\n        - Component needs to be able to handle all combinations\n\n# User interface\n## Views\n- To build a UI Views are used???\n    - Has a lot of attrubutes that can be set\n- View\n    - A rectangle that appears on the screen\n    - Handles drawing and event handling\n- All basic widgets extend from a view\n\n### View attributes\n- Widht \u0026 height\n    - how child is laid out is dependent on its parent\n    - View widht \u0026 height show this well through their special attribte values\n        - wrap_content\n        - match_parent\n- Gravity\n    - 2 types\n        1. gravity attributes of text fields sets the position of the text inside a View\n        2. layout_gravity of a View positions the view relative to the parent layout\n- Padding and margin\n    - padding hsift content inside the View itself\n    - layout_margin adds a margin around the View and\n    - Both can be set\n        - Per edge: Top, Left, Bottom, Right\n        - For all edges at once\n- Visibility\n    - Every view has a visibility attribute\n    - 3 options\n        1. Visible\n        2. Invisible\n        3. Gone\n    - The attribute can be set durign runtime\n        - `setVisibility(View.INVISIBLE);`\n\n## View Groups\n- Multiple view together go in ViewGroups\n    - Base class for Android layouts\n    - Extends from View\n\n## Layouts\n- ViewGroups extends from view (why is this under layouts?)\n- ViewGroups can be nested\n- Lots of possibilities to create layouts (I hope so)\n- Nesting Results in decreased performance\n\n### FrameLayout\n| Class Name       | Description                                                                                                               |\n|------------------|---------------------------------------------------------------------------------------------------------------------------|\n| LinearLayout     | Displays views in a single column or row.                                                                                 |\n| RelativeLayout   | Displays views positioned relative to each other and htis view.                                                          |\n| FrameLayout      | A ViewGroup meant to contains a single child view.                                                                        |\n| ScrollView       | A FrameLayout that is designed to let the user scroll through the content in the view.                                    |\n| ConstraintLayout | This is a newer viewgroup; it postions views in a flexible way. We'll be exploring constraintslayout later in the lesson. |\n| GridLayout       | A layout that places its children in a rectangular grid.                                                                  |\n\n#### Frame\n- Display one View that is placed in the top left corner\n- Other View added will stack on top of eacht other\n\n#### Linear\n- Child Views are oredered horizontally or vertically\n- Each child can be given a weight to give it more or less space than the other Views\n\n#### Grid\n- Layout divided in cells for each View\n- View can span multiple cells\n\n#### Relative\n- Specify for each View if they should be aligned to parents edges\n- Specify for each View howthey should be aligned relative to each other\n\n#### Constraint\n- Allow to place Views relative to parent and toher Views\n- Uses contraints to specify how each View should be positioned and scaled accordingly  \n    relative to other views\n-  Allow for complicated layouts without having to nest different layouts\n- Views added in designer wil be set to left \n- To position a view, atl east 2 constreaints need to be added for that view\n    1. 1 horizontal\n    2. 1 vertical\n- Allow for every complex layouts without nesting ViewGroups\n- Views can be easily moved together\n\n## Constraints\n- Are defined the 'app' namespace\n    - Attributes start with app: instead of android: \n    - Automatically added with ConstraintLayout\n- Defined as edge connection to edge of other view\n- Keeps Views aligned to each other\n    - Layout_constraintLeft_toLeftOf\n    - Layout_constraintTop_toTopOf\n    - ..\n- Keeping views next to each other\n    - Layout_contraintLeft_toRightOf\n    - Layout_constraintTop_toBottomOf\n    - ...\n\n## Responsive Design\n- Different layouts can be used for different screens\n- An app can look differently depending on the\n    - Screen size\n    - Orientation\n- Parts that look the same in different layouts can be move to their own layout files\n    - then inculded in hte main layout files\n    - Make sure to not have an include loop\n\n## Localization\n- Translation of text trhough the strings.xml file\n- New values folder in the res directory for other languages/countries\n    - values-xx-xx with\n        - first xx abbreviation of language\n        - second xx abbreviation of region\n- Copy needed strings from strings.xml and reanslate to the other language\n- Strings for keys or names don't need to be translated\n\n# RecyclerView\n- Mechanism to be able tos croll through thousands of itmes without getting memory constraint\n- More advanced and flexible version of ListView\n- Flexible view for providing a limited window into a large dataset\n- Several different components work toghether to display the data\n    - RecyclerView object\n    - Layout manager\n    - ViewHolder objects\n    - Adpater\n\n\n## How it works\n1. RecylerView has an adapter that provides views when needed\n2. Adpater vinds data from a dat source to the RecyclerView\n3. Adapter sends view through an object called a ViewHolder to the RecyclerView\n4. LayoutManager tells RecyclerView how to layout the views\n\n\u003cimg src=\"./assets/recyclerview-structure.png\" width=\"420\"/\u003e\n\n1. The RecyclerView first asks the adapter how many items it wil have to display\n2. RecyclerView asks adapter to create ViewHolder objects and inflate views from  \n    XML, by calling `onCreateViewHolder()`\n3. Adapters `onCreateViewHolder()` is responsible for creating views and returning ViewHolders\n    objects associated with these views\n3. After ViewHolders are created, RecyclerView\n    will call adapters `onBindViewHolder()` to populate\n    each item with data\n4. When scrolling, RecyclerView reuses ViewHolders asking the adapter to bind\n    new data to them\n\n## Optimizations\n- When first populated\n    - Creates and vinds data to view holders in view\n    - Creates and vind extra view holders on either side of on-screen list\n- When scrolling\n    - Creates new view holders ans necessary\n    - Saves off-screen view holders for reuse\n    - Wheb scrolling back: brings back view holders\n    - When scrolling further: Rebinds new data to view hodlers that have  \n        been off-screen longest\n- Wheb displayed items change\n    - Notify adpater by canceling a notify method\n    - Adatoper rebinds only the affected items\n\n## Layoutmanager\nThe layout manager is a key part in the way recyling viewholders works\n- Determines when to recyle item view that are nog longer visible\n- Three stendard implementations\n    1. LinearLayoutManger  \n        Scrolls vertically (default) or horizontally\n    2. GridLayoutManager  \n        Arranges items in a grid\n    3. StaggeredLayoutManager  \n        offset gird of items\n\n## Viewholder\nConstainds refernece to biew object of the item\n- Are cached\n    - Only load them once (findViewById) wheb created\n- Example: 30 items, 4 views each\n    - 8 onscreen + 2 extra\n    - No caching\n    - ? How many extra calls to findVieById ?\n\n## Recyclerview Items\nAn items is what will be displayed and wil be cached by a ViewHolder object\n- Consists of one or more views\n- Defined in a separate layout xml file\n\n## Adapter\nSeparate class that extand from `RecyclerView.Adpater\u003cViewHolder\u003e`\n- Has a public constructor to create the adapter and initialize members\n- Create new items in th form of ViewHolders\n    - `onCreateViewHolder()`\n        - Inflates items\n        - Instantiates new ViewHolders by calling constructor of inner class\n- Populates items with data\n    - `onBindViewHolder()`\n        - Called when view needs to be populated with data\n- Returns information about the data (how many items)\n    - `getItemCount()`\n        - Returns number of items in data source\n\n## Listener interface\nAn interface to define the listener (never would have gussed that)\n- Implements one function\n    - Takes the clicked item index\n- Adapter class needs to store a reference to the listener in member variable\n    - Constructor takes extra paramter: the listener\n    - Listener paramter is tored in member variable\n\n# Networking \u0026 Threading\n## URI\nUnifrom Resource Identifier\n\n- String of characters taht identifies a resource\n    - URL for we and network\n    - GEO for physical location\n    - ...\n- Has a lot of parts, most of which are optional\n- For the resource types http, https, ftp, geo, ...\n    - [OPTIONAL] Authority\n        - [OPTIONAL] Username:Pasword\n        - [OPTIONAL] Port\n- Path: points to resource\n    - scheme:[//[user:password@]host[\"port]]path[?query[\u0026extraquery]][#fragment]\n\nTODO: this entire chapter\n\n# Storing Data: Database\n- SQLite\n    - 2 operation modes\n        1. Read Only\n        2. Read/Write\n    - CRUD operations\n        - **C**reate -\u003e Insert (W)\n        - **R**ead   -\u003e Query  (R)\n        - **U**pdate -\u003e Update (W)\n        - **D**elete -\u003e Delete (W)\n    - Interal Storage\n        - Private to your app\n\n## Storing steps\n1. Define schame and contract\n2. Craete database\n3. Put info in database\n4. Read info from database\n5. Delete info from database\n6. Update database\n\n## Database contract\n- Feed reader\n```java\npublic final class FeedReaderContract {\n    private FeedReaderContract() {}\n    public static class FeedEntry implements BaseColumns {\n        public static final String TABLE_NAME = \"entry\";\n        public static final String COLUMN_NAME_TITLE = \"title\";\n        public static final String COLUMN_NAME_SUBTITLE\n            = \"subtitle\";\n    }\n}\n```\n\n## Database creation\n- Create helper class\n    - Extension class from SQLiteOpenHelper\n        - Create database for first time with info from Contract class\n    - Gives a means to update database schema\n    - Provides a reference to database for other classes\n        - Potentially long running operations will only be performed when needed\n    - SQLiteOpenHelper\n        - 2 important constants\n            1. DATABASE_NAME: name of the file for the database\n            2. DATABSE_VERSION: verson number of the database\n        - 2 important methods\n            1. `oncreate`: creating database for the first time\n            2. `onUpgrade`: keeping database schema up to date\n\n    - To access the database this class needs to be instantiated\n\nTODO: Cursors\n\n# Prefrences\nThe act of saving data to the phone\n5 ways on android\n1. onSavedInstanceState\n2. SharedPreferences\n3. SQLite Database\n4. Internal/Extertnal storage\n5. Server\n\n| Persistence Option | Type of data saved | Length of time saved |\n|-|-|-|\n| onSaveInstanceState | key/value (complex values) | While app is open |\n| SharedPreferences | key/value (primitive values) | Between app and phone restarts |\n| SQLite Database | Organized, more complicated text/numeric/boolean data | Between app and phone restarts |\n| Internal/External storage | Multimedia or larger data | Between app and phone restarts |\n| Server (Ex. Firebase) | Data that multple phones will access | Between app and phone restarts, deleting the app, using a different phone, ... |\n\n## OnSavedInstanceState\n- Used to store data to restore the state of view\n    - After screen rotations\n    - In change of screen widht\n    - When activity is destroyerd by system (memory constraints)\n- When activity recreated, original state recreated\n- Data only stored during active app use\n- Data stored in object called Bundle\n- Key-value pairs\n\n## SharedPrefrences\n- A file to store simple key-value pairs\n    - Key is a string\n    - Value is a primitive type\n- Used to store simple information about a user\n    - Player's name in a game\n    - Last visited website\n- used to store settings in an app\n    - Through a PreferenceFragment\n- Stored in filesystem\n    - Accessible as long as phone works and app hasn't been uninstalled\n\n#### PreferenceFragment\n- Subclass of fragment class\n- Specifically for settings\n- Provides standard layout\n- Preferences defined using XML\n    - Generates UI widgets in the fragment\n    - Comparable to inflating layout XML files\n- Updates in PreferenceFragment updates the SharedPreferences file\n\nTODO: Setup prefrences\n\n\n## Database\n- SQLite internal database provided\n- Stores more complicated information\n- Accessible directly or with ContentProvider\n\n## File Storage\n- 2 types\n    - Internal storage: HDD in phone (Euhm HDD?!)\n    - External storage: SD-card\n- To store large amounts of data\n    - Multimedia: Video, Audio, Pictures\n    - Large amounts of text\n\n## Online storage\n- Data stored online\n    - Own server\n    - Cloud service like Firbase\n- Accessible by different devices\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdbe%2Fapp-dev-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvdbe%2Fapp-dev-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdbe%2Fapp-dev-notes/lists"}