0% found this document useful (0 votes)
79 views12 pages

Grocery List - An Android Application

This document describes an honors research project where a student created an Android application for managing grocery lists. The goals of the project were to learn about app development and decide if it was a suitable career path. The student researched the basics of the Android framework and implemented features like an editable text field for the list, a save button to write the list to a file, and an open function to load a previously saved file. The project helped the student learn about tools like Android Studio, activities, intents, files and more. Overall, the project was a success in creating a functional grocery list app and helping the student explore app development.

Uploaded by

jpaul42391
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views12 pages

Grocery List - An Android Application

This document describes an honors research project where a student created an Android application for managing grocery lists. The goals of the project were to learn about app development and decide if it was a suitable career path. The student researched the basics of the Android framework and implemented features like an editable text field for the list, a save button to write the list to a file, and an open function to load a previously saved file. The project helped the student learn about tools like Android Studio, activities, intents, files and more. Overall, the project was a success in creating a functional grocery list app and helping the student explore app development.

Uploaded by

jpaul42391
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

The University of Akron

IdeaExchange@UAkron
The Dr. Gary B. and Pamela S. Williams Honors
Honors Research Projects
College

Spring 2018

Grocery List: An Android Application


Daniel McFadden
djm188@zips.uakron.edu

Please take a moment to share how this work helps you through this survey. Your feedback will be
important as we plan further development of our repository.
Follow this and additional works at: http://ideaexchange.uakron.edu/honors_research_projects
Part of the Other Computer Sciences Commons

Recommended Citation
McFadden, Daniel, "Grocery List: An Android Application" (2018). Honors Research Projects. 683.
http://ideaexchange.uakron.edu/honors_research_projects/683

This Honors Research Project is brought to you for free and open access by The Dr. Gary B. and Pamela S. Williams
Honors College at IdeaExchange@UAkron, the institutional repository of The University of Akron in Akron, Ohio,
USA. It has been accepted for inclusion in Honors Research Projects by an authorized administrator of
IdeaExchange@UAkron. For more information, please contact mjon@uakron.edu, uapress@uakron.edu.
Dan McFadden
4/6/2018
Honors Project: Grocery List Android App
Introduction

When trying to think of a idea to do for this research project, I had a tough time coming

up with something that would be considered "non trivial." So, after much deliberation, I

eventually decided to go out of my comfort zone and try something completely new to me: App

development. I've always wanted to create my own app, and even one day potentially be an app

developer. So I figured, why not start now? Once I decided that, I just thought of a practical

concept that I could turn into an application for people to use.

The goal of this project was mainly to learn something I've never learned before to see

how far I could take it. Another goal of mine in completing this project was to ultimately decide

for myself if app development was really a path I wanted to consider for my future. I've never

worked with Android Developer or XML before, so I knew ahead of time that this project would

be a difficult, but a very helpful learning experience.

Planning

Before I could even begin to start diving into the world of app development, I laid out

certain expectations for myself and what I wanted to accomplish with this project. This first goal

I wanted to meet for myself was to learn and understand the basics of what goes into an Android

app. My only other goal for this project was to ultimately have a finished product that I could be

proud of. I knew that my first app wouldn't be perfect, but if it accomplishes the goal that I
wanted to, which is to be able to act successfully as a grocery list application, then I would be

pleased with my final product.

Now, with my goals set in mind, I had to try and come up with a basic layout that I

wanted my app to look like and what tools I would have to use to achieve that layout. The layout

I wanted was very simple, just a list that the user could type into to add whatever items they

needed to shop for, and the ability to save that list for future use if they wanted to plan out their

shopping ahead of time. I essentially wanted to offer everything a person can get from using pen

and paper, but without the pen and paper.

Implementation

To kick things off, I needed to learn the basic structure of Android's framework. When

you first create a basic activity using Android developer, there are a few things that are created

which start you off with a default layout, similar to a "hello world" program in C++ or another
language. You first have a MainActivity.java file which controls what you want your app to do

when the user interacts with it. Secondly, you have the AndroidManifest.xml file, which is what

is called when the app is first launched from the user's device. This sets up the app into its initial

state, which you can specify by changing the pre-defined code within the manifest file. Lastly,

you have another xml file that corresponds to your main activity and controls the visuals and

layout of that particular activity. If you wanted to add things to that activity, like I do, you would

instantiate them in this file.

Now that I've begun to understand the general structure of Android apps, I could finally

begin to craft my project. The first thing I noticed was that the default application displayed

"Hello World" to the activity screen. This led me to the text view created inside one of my XML

files. With a little research into the Android API, I came across the edit text object, which

worked similarly to a text view, except you could type into it as opposed to just printing text to

it. From there, I created the edit text object, and was able to modify the size of the text box by

dragging the corners of the box using the design tab within Android Developer. Low and behold,

just like that I had a text field where users could create their grocery lists.
Grocery list with sample items in the text field

Having a text field was all fine and good, but it doesn't do the user any good if you can't

save that text field for future access, like when they are out buying groceries. So I had a few

options to do this, I could either create a database which could store all the users different

grocery lists, or I could save the notes internally. In this situation, it didn't make much sense to

store the notes in a database, plus I've also already worked with database access in previous

projects, so I decided to figure out how to save the notes internally to the device. To do this, I

would need to get a reference to a file object, and then save it using a file output stream.

In order for the user to be able to save to a file, I would need something included in the

app's interface for them to do so. So, after exploring my options, I decided to go with a FAB, or

floating action button. FABs are just buttons you can include in your app that are somewhat

customizable, and helpful for accomplishing tasks like saving data to a file. All the user would
have to do is press the FAB, and their grocery list would be saved. As you can see below, the

app's progress thus far contains the edit text field as well as the FAB with a save icon overlaying

it.

The first screen that the app opens to upon first launch.

Now that we have our FAB created, we can now think about how to save to a file. The

best way I found to go about this was to create a save function inside of the MainActivity.java

file that would accept a String filename which would be the contents of the edit text field. From

there, I opened an output stream writer which would open up the file we want to save the grocery

list to, write the grocery list contents to the output stream writer, and then close the output

stream. The last thing I wanted to include with this function was a short message that the user

could see once they save their file. To do this, there is an object in Android's API called Toast,

which basically allows you to display short feedback dialogs for a second, then they disappear.

So I made my Toast object simply output "Saved" to the screen so the user would know their file

is saved. The last thing I needed to do was go back into my FAB and tell it to call the save

function when it is clicked.


Code snippet of my save function using the toast object to write to the screen.

At this point, things are looking pretty good for what I want to accomplish in this project,

I've learned a lot about Android Studio and Android app development, but I'm not finished yet.

The next thing that I needed to figure out was how to load in the file that we just saved. So the

first thing I did was create a short function to check if a file exists or not, called fileExists. All it

does is take in a file name, create a dummy File object to receive the contents of the passed in

file name, and then check if that dummy file exists and returns true or false. Now that fileExists

is set up, I could create an open function to open up that filename using an input stream, buffered

reader, and a string builder. To explain how this function works, I create an input stream which

takes in the name of the grocery list, (making sure to check first if the file exists using fileExists)

then I make an input stream reader which takes in the input stream. After that I need to make a

buffered reader which takes in the input stream reader. Then, I make a dummy string variable

and a String builder object which I use to iterate through each line of the file and append it to the

dummy string variable. Lastly, I close the input stream and use the empty string called "content"

to save all the contents that were loaded into my dummy string and return content.
Code snippet of the open function which opens the most recently saved grocery list.

Now that I have an open function that works, I decide to call this function in the onCreate

method within my main activity class. I do this so that once the user launches the app, their most

recently saved grocery list will already be loaded in automatically, and they wouldn't have to

search for it or manually load it in themselves. Therefore, at this point I have achieved the

ultimate goal I wanted in creating a grocery list app for Android! However, I still felt as though I

wanted to learn more about app development as a whole, so I started to brainstorm new ideas.

The biggest innovation to my existing app that I could think of would be to add the ability to

create multiple grocery lists for the user, if they needed to make separate lists for different stores.

In order to accomplish this task, I first needed to add another activity to display a list of

all the existing lists that the user would create. So, I created a new activity that would be able to

handle this functionality. My first obstacle once the new activity was created was how I would

display all the saved grocery lists. To do so, I decided to use a recycler view, which is a more

advanced version of a list view. It acts as an object that I can store all the different lists in. Once I
added a recycler view called "notes" to the new activity's XML file, I needed to create a note

builder java class so I could store all of the notes in the recycler view. The note builder class was

made to provide getter functions to access the contents of each list for the display. Once that was

set up, I added a new XML file to handle the layout of each different list as it would appear in

the recycler view. To keep things simple, I just used two text views to display the file name

corresponding to each list, as well as one to show the first line of text in the particular list.

The base layout of the recycler view before any lists are added

to it.

Now that I have my recycler view set up, I needed to make one more java file that would

attach all of the list notes to the recycler view, otherwise known as the notes adapter class. The

note adapter class essentially goes through the content of all the created grocery lists and stores

their content into a list of grocery lists. Lastly, I needed to modify the note select activity that I

created to display all this to properly display all the grocery lists and be able to find them. So I

first modified the on create method to initialize my notes adapter and recycler view to their
layouts. Then the last thing I do in the on create method is call a function called prepare notes.

Prepare notes accesses the file directory of the device, and iterates through all the existing files

and assigns them a default name such as "list 1", opens up the file by using note builder, and then

adds the opened file to the list of grocery lists. With that being completed, I have reached the

current status of my project right now, with the additional feature mostly implemented, but not

quite completed yet. Regardless of this, I still have accomplished what I desired plus some extra,

so I am very content with the results of my honors project!

Display of the recycler view with 1 grocery list saved to it


Future Work/Takeaways

I think that the biggest takeaway from completing this project was that I shouldn't be

afraid to try something new. For the longest time, I viewed app development as something that I

would never be able to do, simply because I never tried to figure out how to get involved in it.

Having now completed my own first Android app, although it is not by any means perfect, I've

learned a lot of the basic concepts behind making an app, which is something I never thought I

would come to know. Looking ahead, some future work I could further put into this app would

be significantly improved graphics. Right now, my app uses all default layouts, as well as my

FABs, which I know can all be customized somehow. However, in planning for the project I

wanted to focus on implementation before I spent too much time on improving graphics. So if I

could learn how to create my own personalized layouts, FABs, or any other thing within the

framework that is customizable, I would not hesitate to make my project more visually

appealing.

Based on the current state of my grocery list app, a future implementation I could create

would be to generalize the purpose of the app altogether. For instance, instead of just making the

app exclusively for grocery lists, I could broaden the purpose to just general note taking. That

way the app could see multiple uses and potentially be more appealing to users. However, if I

were to stick with my initial idea, I would want to implement the ability to access databases of

all retailers across the United States. Now I know this may not even be possible to implement,

but perhaps a simpler version of this idea could be done. I could potentially create my own

database that I populate with all different foods from the main food retailers and allow the user to

search through that database and manually add the different products they want to their grocery

list. I could even save pictures of all the products that could also be included in the grocery list.
That way I could renovate the way that people shop for food everyday by providing an easy to

use application where you can search for any possible food you may need. If I could make the

process even more elaborate, I could attempt to add functionality that would be able to say if

your desired product was in stock as well as have a price range across different food chains.

Thinking about it now, these ideas are somewhat above and beyond any expectation I could ever

imagine, and if I could one day actually make these ideas a reality, I don't think I'd be able to

express the enjoyment I would feel.

Conclusion

I use different applications on my phone every single day, and with the way that these

different technologies are revolutionizing society is truly mind blowing. I couldn't even imagine

a day where I didn't have a cell phone to check, or an app to play in my free time. This fact alone

proves that app development will never be a useless skill to have, because we as a society will

only grow to expand its concepts more and more.

I'm very pleased to have taken on this project and to have finished it with results that

were above my expectations. Developing apps is a skill that I know will help me become even

more versatile when it comes to software development. Learning the basics, successfully

implementing learned ideas, and creating a finished product is a process that I will live enjoy for

a very long time.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy