<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muaz on Medium]]></title>
        <description><![CDATA[Stories by Muaz on Medium]]></description>
        <link>https://medium.com/@muaz_zulfaqar?source=rss-b309c8dd4f9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lRhhRw0yLfcRmCKO1rk9MQ.jpeg</url>
            <title>Stories by Muaz on Medium</title>
            <link>https://medium.com/@muaz_zulfaqar?source=rss-b309c8dd4f9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:22:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muaz_zulfaqar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 3]]></title>
            <link>https://medium.com/@muaz_zulfaqar/sqldelight-android-example-xml-sqldelight-crud-notes-app-part-3-53741c55620?source=rss-b309c8dd4f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/53741c55620</guid>
            <category><![CDATA[sqldelight]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[coroutine]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-flow]]></category>
            <dc:creator><![CDATA[Muaz]]></dc:creator>
            <pubDate>Thu, 27 Oct 2022 18:10:47 GMT</pubDate>
            <atom:updated>2022-10-27T18:10:47.871Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8d8Hx9lAYKP4aTbR1tOmkg.png" /><figcaption>Notes Android App with SqlDelight Part-3</figcaption></figure><p>In case you have missed the second part of this series, kindly have a look at that;</p><p><a href="https://medium.com/@muaz_zulfaqar/sqldelight-android-example-xml-sqldelight-crud-notes-app-part-2-f1f858c3d280">SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 2</a></p><p>Welcome to the third part of making <strong><em>CRUD</em></strong> operations with <a href="https://cashapp.github.io/sqldelight/android_sqlite/">SQLDelight</a> on Android. ⚡️ Let’s finish things…..🔥</p><h4>💥 Enable View Binding in the project:</h4><p>Add this to the build.gradle(app-level) file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/154755aa567fb6dd5263461102bd940d/href">https://medium.com/media/154755aa567fb6dd5263461102bd940d/href</a></iframe><h4>💥 Create BaseFragment class under base package:</h4><p>The View Binding in fragments required a lot of work than in activity. I have got this class from this <a href="https://github.com/wajahatkarim3/Imagine/blob/main/app/src/main/java/com/wajahatkarim3/imagine/base/BaseFragment.kt">repository</a>. The showSnackBar() will reduce the repetition of writing code for Snackbar.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/514aaa1cb1310cc8bcab7d0e0453b9e9/href">https://medium.com/media/514aaa1cb1310cc8bcab7d0e0453b9e9/href</a></iframe><h4>💥 Create BottomSheetBaseFragment class under base package:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c42ab4af22640d66e063ad387cbeefdf/href">https://medium.com/media/c42ab4af22640d66e063ad387cbeefdf/href</a></iframe><h4>💥 Set up MainActivity:</h4><p>We are using Android Jetpack <a href="https://developer.android.com/guide/navigation/navigation-getting-started">Navigation components</a> to handle fragments efficiently. We need to add <strong><em>FragmentContainerView</em></strong> for displaying fragments in the MainActivity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e68e452f20e1f6cdd573904c53c1ecf4/href">https://medium.com/media/e68e452f20e1f6cdd573904c53c1ecf4/href</a></iframe><p><strong><em>@AndroidEntryPoint </em></strong>is the necessary annotation for Activities, Fragments, and Services that use dependencies created by Hilt.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4625642d4260f0341a51aa8d799170ab/href">https://medium.com/media/4625642d4260f0341a51aa8d799170ab/href</a></iframe><h4>💥 Create Fragments:</h4><ol><li>Create 2 packages under the <strong><em>ui </em></strong>package; home and upsert.</li><li>Create HomeFragment under ui-&gt;home package and UpsertNoteFragment under ui-&gt;upsert.</li></ol><h4>💥 Set up NavGarph:</h4><p>Our first screen will be HomeFramgnt that&#39;s why we make it startDestination with the action to start the bottom sheet. We also add the UpsertFragment as dialog because we need to show this as BottomSheet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36a4c47c4eab0309c645264a9596ec98/href">https://medium.com/media/36a4c47c4eab0309c645264a9596ec98/href</a></iframe><h4>💥 Create NotesSharedViewModel:</h4><p>This is the only ViewModel in our project that will;</p><ol><li>communicate with NotesDataSource(that will perform database operations)</li><li>hold the selected note and share it between the home screen and the bottom sheet.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/633c7f3437bc81b211dc128737a41af0/href">https://medium.com/media/633c7f3437bc81b211dc128737a41af0/href</a></iframe><p><strong><em>@HiltViewModel</em></strong> is a special annotation for Viewmodels. The NotesDataSource will be provided from the Hilt. The upsertData(), deleteNote(), getAllNotes() are self explanatory. We are using flow builder for collecting and emitting notes to the fragments.</p><p>We are using sharedNote as a <a href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-state-flow/">MutableStateFlow</a>. It will store value as a state. We have set its initial value to the NotesEntity with dummy values.</p><h4>💥 Wirte code in UpsertFragment:</h4><p>This fragment is used for creating new notes and updating the existing ones.</p><p>Let&#39;s see what its XML looks like;</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdc40f522ac8da735dc3cf594cfeb40f/href">https://medium.com/media/fdc40f522ac8da735dc3cf594cfeb40f/href</a></iframe><p>You can see <strong><em>CoordinatorLayout </em></strong>at the top because it will help Snackbars to show efficiently in the bottom sheet.</p><p>Now, its time to see what’s in the UpsertNoteFragment.kt file;</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82313445483327ea145a7715f7d1b0b3/href">https://medium.com/media/82313445483327ea145a7715f7d1b0b3/href</a></iframe><p>Here are some points to mention;</p><ol><li><strong><em>@AndroidEntryPoint</em></strong> because it’s a fragment</li><li><strong><em>BottomSheetBaseFragment&lt;FragmentUpsertNoteBinding&gt;(): </em></strong>using the base fragment view binding implementation here. We need to implement <strong><em>bindingInflater </em></strong>from the base class. And now we have access to the <strong><em>binding </em></strong>variable<strong><em>.</em></strong></li><li><strong><em>activityViewModels() </em></strong>is used because the ViewModel is shared between 2 fragments.</li><li>We are getting the value of selectedNote from the shared ViewModel, we will check if it contains the dummy title, and we will perform the insertion. Otherwise, we will show the title and description and update the note.</li><li>We are using apply <a href="https://kotlinlang.org/docs/scope-functions.html">scope</a> function on the binding variable. So, no need to call binding. again and again.</li></ol><h4>💥 Wirte code in HomeFragment:</h4><p>In this fragment, we will show the list of notes and add an action to open UpsertFragment.</p><blockquote><strong>Home Fragment (XML):</strong></blockquote><p>A RecylcerView to show notes and fab to open the bottom sheet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06f7ff07e927c8f40f2cf6761cd30294/href">https://medium.com/media/06f7ff07e927c8f40f2cf6761cd30294/href</a></iframe><blockquote><strong>HomeFragment.Kt:</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfa5be3261addc307e08a15237662467/href">https://medium.com/media/bfa5be3261addc307e08a15237662467/href</a></iframe><p>Let&#39;s discuss some points here;</p><ol><li>On click of fab, it means the user wants to add a new note, we will just set the value of sharedNote to a dummy note.</li><li>We have created NotesAdpater, you can find it <a href="https://github.com/muazdev26/Notsi/blob/master/app/src/main/java/com/muazdev/notsi/ui/home/NotesAdapter.kt">here</a>. It is a ListAdapter. We added 2 buttons as well for deleting and editing a single note. When the user clicks on one of those buttons, corresponding functions will be called from the ViewModel.</li><li>We are submitting the notes list to the list adapter by collecting the flow from ViewModel. Collecting flows in fragments is tricky, you can find a very good read <a href="https://medium.com/androiddevelopers/a-safer-way-to-collect-flows-from-android-uis-23080b1f8bda">here</a>.</li></ol><p>And that’s it. Our notes app is completed now with SQLDelight.</p><p>Here is the complete repository to find the code;</p><p><a href="https://github.com/muazdev26/Notsi">GitHub - muazdev26/Notsi: Notes Android App with SqlDelight</a></p><p>Hope you will enjoy this series. Keep Coding 👨🏻‍💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53741c55620" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 2]]></title>
            <link>https://medium.com/@muaz_zulfaqar/sqldelight-android-example-xml-sqldelight-crud-notes-app-part-2-f1f858c3d280?source=rss-b309c8dd4f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1f858c3d280</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[notesapp]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[sqldelight]]></category>
            <category><![CDATA[dagger-hilt]]></category>
            <dc:creator><![CDATA[Muaz]]></dc:creator>
            <pubDate>Wed, 26 Oct 2022 17:05:35 GMT</pubDate>
            <atom:updated>2022-10-26T17:05:35.924Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysx6VJpbnCbtqhGdrvo6Qw.png" /><figcaption>Notes Android App with SQlLDelight Part-2</figcaption></figure><p>In case you have missed the first part of setting up SQLDelight, kindly have a look at that;</p><p><a href="https://medium.com/@muaz_zulfaqar/sqldelight-android-example-xml-sqldelight-crud-notes-app-part-1-8688996b3e2b">SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 1</a></p><p>Welcome to the second part of making <strong><em>CRUD</em></strong> operations with <a href="https://cashapp.github.io/sqldelight/android_sqlite/">SQLDelight</a>. ⚡️ Let&#39;s continue…..🔥</p><h4>Create 4 packages under your main package:</h4><ol><li>✨ base — for base fragment classes</li><li>✨ data-&gt;local — for local data source classes</li><li>✨ di — for dependency injection using Dagger Hilt</li><li>✨ ui — for fragments, activities, viewmodels, adapters classes</li></ol><figure><img alt="Packages creation for notes app sqldelight" src="https://cdn-images-1.medium.com/max/1024/1*r6lsTPjHbdtCsoXZJhDrSQ.png" /><figcaption>Package creation for notes app sqldelight</figcaption></figure><h4>💥 Create NotesDataSource interface under data-&gt;local:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8734bea1bc7fdd60fc9ba698704b8e8/href">https://medium.com/media/c8734bea1bc7fdd60fc9ba698704b8e8/href</a></iframe><p>Wait a minute…..🌚 From Where this mysterious <strong><em>NotesEntity</em></strong> came?</p><p>This is an auto-generated class created from the SQLDelight plugin for us from our table notesEntity.</p><blockquote>Note: If you are not seeing <strong><em>NotesEntity, </em></strong>Rebuild the project again.</blockquote><p>We have defined 4 functions;</p><ol><li><strong><em>getSingleNote(id: Long):</em></strong> This is a suspend function that will return us a single note. The parameter id type is surprisingly Long not Int because the auto-generated class makes <strong>“id INTEGER” </strong>to <em>Long</em>.</li><li><strong><em>getAllNotes():</em></strong> It will return a list of notes that is wrapped by the <a href="https://developer.android.com/kotlin/flow">flow</a>. We are using flow because it also works asynchronously and gives us an updated notes list.</li><li><strong><em>deleteNote(id: Long): </em></strong>It will take the specific note id and delete it.</li><li><strong><em>upsertNote(id: Long? = null, title: String, description: String): </em></strong>This function provides the insertion of a new note and updating an existing note. The id will be <strong>null</strong> while insertion.</li></ol><h4>💥 Create NotesDataSourceImpl class under data-&gt;local:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a8cd4522ead95b283bcd80de773f84d/href">https://medium.com/media/0a8cd4522ead95b283bcd80de773f84d/href</a></iframe><p>The NotesDataSourceImpl implements the NotesDataSource interface. This class takes 2 parameters.</p><ol><li><strong><em>notesDb: NotesDb: </em></strong>This NotesDb is also an auto-generated class. The name is NotesDb is described by us in the build.gradle(app-level) file in the previous part.</li><li><strong><em>dispatcher: CoroutineDispatcher: </em></strong>This is a coroutine dispatcher for running asynchronous database tasks.</li></ol><p>Now, to access the queries we have written in <strong><em>notesEntity.sq </em></strong>for CRUD operations, There is another auto-generated interface named <strong><em>NotesEntityQueries </em></strong>which converts queries into functions. So, we can access it via <strong><em>notesDb.</em></strong></p><pre>private val queries = notesDb.notesEntityQueries</pre><p>The 4 functions&#39; implementation is self-explanatory. <strong><em>executeAsOneOrNull()</em> </strong>means getSingleNote() returns 1 or no records for given id.</p><p>That’s it for the data package. Now let&#39;s write some code in the <strong>di </strong>package.</p><h4>💥 Create NotesApp class and AppModule using Dagger <a href="https://developer.android.com/training/dependency-injection/hilt-android">Hilt</a>:</h4><ol><li><strong>Create NotesApp:</strong></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bd5a28943d8eeda789f6f40df2b80ac/href">https://medium.com/media/6bd5a28943d8eeda789f6f40df2b80ac/href</a></iframe><p>Register it in AndroidManifest.xml:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65b95658a2a268f31811b0ae396ab5fd/href">https://medium.com/media/65b95658a2a268f31811b0ae396ab5fd/href</a></iframe><p><strong>2. Create App Module:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c707a8e1ab82cf5d99891aec2b6cdf5a/href">https://medium.com/media/c707a8e1ab82cf5d99891aec2b6cdf5a/href</a></iframe><p>Let me explain each function;</p><blockquote><strong><em>provideSqlDelightProvider():</em></strong></blockquote><p>It will provide How SqlDriver will be created. <strong><em>SqlDriver</em></strong> provides connection to the database and APIs for managing transactions and executing SQL queries/statements. NotesDb is the auto-generated class, from which we can get Schema. You can name the db whatever you want(notes.db in my case).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dba680b0f7c320dbce9b57c92c8fe0c8/href">https://medium.com/media/dba680b0f7c320dbce9b57c92c8fe0c8/href</a></iframe><blockquote><strong>provideNotesDataSource(), providesDispatcher():</strong></blockquote><p>To interact with NotesDataSource, we will need to expose it to to the ui layer i.e. viewmodels. provideNotesDataSource will do that.</p><p>We need to pass dispatcher to the <em>provideNotesDataSource()</em>. For that we have created <em>providesDispatcher(). </em>We choose <strong><em>Dispatchers.IO</em></strong> becuase its recommended to perform database opertaions on IO not on main.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45c3bf5d68dd8c4b250956eed91d4df1/href">https://medium.com/media/45c3bf5d68dd8c4b250956eed91d4df1/href</a></iframe><p>That’s it for the second part. 😇 We will continue to write some XML, viewmodels in the upcoming part. 😎</p><p>Thanks for reading ✨ and Stay Tuned… 👨🏻‍🎓</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1f858c3d280" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 1]]></title>
            <link>https://medium.com/@muaz_zulfaqar/sqldelight-android-example-xml-sqldelight-crud-notes-app-part-1-8688996b3e2b?source=rss-b309c8dd4f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8688996b3e2b</guid>
            <category><![CDATA[dagger-hilt]]></category>
            <category><![CDATA[sqldelight]]></category>
            <category><![CDATA[notesapp]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Muaz]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 08:04:42 GMT</pubDate>
            <atom:updated>2022-10-26T17:07:27.790Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TTiU4E4I2wqsmh4zyMTdhA.png" /><figcaption>Notes Android App with SqlDelight</figcaption></figure><p>Hello, Android devs! I hope you are enjoying using <a href="https://developer.android.com/training/data-storage/room">Room</a> as a local data source.</p><p>I came up with another option, <a href="https://github.com/cashapp/sqldelight">SQLDelight</a> which is;</p><ul><li>type-safe</li><li>written in kotlin (recommended for <a href="https://kotlinlang.org/docs/multiplatform-mobile-getting-started.html">KMM</a> too)</li><li>checking your schema and statements at compile-time</li></ul><p>Let’s make a notes app with SQLDelight, Kotlin, Coroutines, Flows, and much more ;)</p><h3>Android Setup</h3><h4><strong>Step-1:</strong> Apply these plugins in your project-level Gradle file;</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ccaf4f59cc22a91ac84d42300b124e4/href">https://medium.com/media/4ccaf4f59cc22a91ac84d42300b124e4/href</a></iframe><p>This is the new style of writing plugins in your project-level Gradle file. Let me explain this style with a simple hack. We all are using this way;</p><pre>classpath &#39;com.squareup.sqldelight:gradle-plugin:1.5.4&#39;<br>classpath &#39;com.google.dagger:hilt-android-gradle-plugin:2.44&#39;</pre><ol><li>Copy till first “:” and skip <strong>“gradle-plugin”.</strong></li><li>Write the remaining keywords adding<strong> “.”</strong> after them(<strong>hilt.android</strong>).</li><li>Note the version i.e. <strong>1.5.4</strong> or <strong>2.44</strong> and replace classpath with <strong>“id”</strong></li></ol><pre>id &#39;com.squareup.sqldelight&#39; version &#39;1.5.4&#39; apply false<br>id &#39;com.google.dagger.hilt.android&#39; version &#39;2.44&#39; apply false</pre><h4><strong>Step-2: </strong>Apply the plugins in the app-level build.gradle file;</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd947fb892c67f0dc31961fb2feafa8f/href">https://medium.com/media/dd947fb892c67f0dc31961fb2feafa8f/href</a></iframe><h4><strong>Step-3: </strong>Adding the dependencies:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f0136fd48462f6a64c8892e7d930494/href">https://medium.com/media/7f0136fd48462f6a64c8892e7d930494/href</a></iframe><h4><strong>Step-4: </strong>Create packages for the table[Tricky part]</h4><ol><li>Switch From android view to project view. Then go to <strong><em>app-&gt;src-&gt;main</em></strong></li><li>Create a new directory named <strong><em>sqldelight </em></strong>in the main.</li><li>Now under the <strong><em>sqldelight </em></strong>directory, create the directories as per your package(I am using <em>com.muazdev.notsi</em>). So, I have created 3 directories under sqldelight; com, muazdev, notsi</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYB-G8I-y1dWpEDY3NkMWg.png" /><figcaption>Project View of SQLDelight</figcaption></figure><h4><strong>Step-5: </strong>Creating Table[notesEntity.sq]</h4><blockquote>First, install one Android Studio plugin SQLDelight by Square</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7pZR2Qwf5RBA8E3Jz6CH3A.png" /><figcaption>SQLDelight Plugin</figcaption></figure><p>After installation might be you need to restart the Android Studio.</p><blockquote>Now go back to the Project view and app-&gt;src-&gt;main-&gt;sqldelight-&gt;com-&gt; muazdev-&gt;notsi, and right click to create table;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pB9X9h7aJNdTM2f_wjs2yA.png" /><figcaption>Creating a table for SQLDelight</figcaption></figure><blockquote>Choose table:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vRSvnoYzI96c0jrHI8Z0cw.png" /></figure><blockquote>Let’s write some SQL for creating the Notes table:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/830cb223e0cdcea082e8cbcffd780779/href">https://medium.com/media/830cb223e0cdcea082e8cbcffd780779/href</a></iframe><blockquote>SQL for the creation and updating of a note[(?, ?, ?) means there will be values for id, title, description]:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84cd674437c2d2d9061e37bdbea795cb/href">https://medium.com/media/84cd674437c2d2d9061e37bdbea795cb/href</a></iframe><blockquote>SQL for reading note(s):</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67e6ac68fba38c9a5c8aee50a6e2f2e0/href">https://medium.com/media/67e6ac68fba38c9a5c8aee50a6e2f2e0/href</a></iframe><blockquote>SQL for deleting a note:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28aa5b126b8befbb2efaeca2f1b93c89/href">https://medium.com/media/28aa5b126b8befbb2efaeca2f1b93c89/href</a></iframe><p>The complete file <strong><em>notesEntity.sq </em></strong>will look as follows;</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/684fe338b2fb0909a045bde1fe4fc83b/href">https://medium.com/media/684fe338b2fb0909a045bde1fe4fc83b/href</a></iframe><h4>Step-6: Generating type-safe classes:</h4><p>Go to build.gradle(app-level) and paste it after the dependencies block. The <strong><em>NotesDb </em></strong>will be the generated class name. You can name it whatever you want.</p><pre>dependencies <strong>{<br>   </strong>implementation &#39;com.squareup.sqldelight:android-driver:1.5.3&#39;<br>   ....</pre><pre><strong>}</strong></pre><pre>sqldelight <strong>{<br>    </strong>NotesDb <strong>{<br>        </strong>packageName = &#39;com.muazdev.notsi&#39;<br>    <strong>}<br>}</strong></pre><p><strong><em>Rebuild</em></strong> the project the files will be generated.</p><p>This is the end of part 1. We will continue to write functions that will interact with SQLDelight in the next part.</p><blockquote><strong>Here is the 2nd part:</strong></blockquote><p><a href="https://medium.com/@muaz_zulfaqar/sqldelight-android-example-xml-sqldelight-crud-notes-app-part-2-f1f858c3d280">SQLDelight Android Example(XML) | SQLDelight CRUD | Notes App — Part 2</a></p><p>Thanks for reading ✨and Stay Tuned… 👨🏻‍🎓</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8688996b3e2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>