Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases.
|
|
- Grant Marshall
- 5 years ago
- Views:
Transcription
1 Managing Data This week, we'll be looking at managing information. There are actually many ways to store information for later retrieval. In fact, feel free to take a look at the Android Developer pages: We could store records in 'the cloud' and retrieve them later, say with some RESTful API. We could create a datafile for our application, and manipulate that. Both have their uses. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases. (Shared) Preferences Why? Consider the following: you load up your preferred calculator app, and switch to 'formula mode'. The next time you open your calculator, wouldn't it be nice if it remembered that you preferred formula mode last time? For that matter, if you had saved a particular value last time, perhaps it would be useful to still have it available upon the next execution? For other apps, think about all of the customizations you typically have: whether or not to silence when you're using the application, whether you want haptic feedback, how often to update weather information, what tune to play for notifications, accessibility preferences, etc. All of these are things that you wouldn't necessarily want to need to reset for each execution. They also have something else in common that we'll explain very soon. What? A 'shared preference' file is a very basic data management file that stores tuples of key-value pairs. There are different use cases (e.g. a single preferences file for the application that's mostly managed for you, a PreferenceActivity to make changing user settings more consistent across applications, multiple explicitlynamed preference files, 'world-readable' preference files so one application can access the user's preferences from another, etc.), but they all have the same basic mechanisms: Open a preference file Read by querying on a key Write by updating a new value for a key Because of the tuple-nature of the data, preferences are not for storing things like complex data, records, etc. Why could the calculator's saved memory be an exception? Because there's always only one memory bank (or always a fixed-size set of memory values). There's no table of records for selecting.
2 There are some very good reads here: Let's try a trivial example, just to demonstrate the mechanism. Let's start with a layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_height="match_parent" tools:context="ca.brocku.efoxwell.a2017_sixthstage.mainactivity" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:text="do we have a preference?" android:id="@+id/preferentialdisplay" <EditText android:id="@+id/preferentialinput" android:onclick="buttony" <Button android:layout_width="wrap_content" android:text="save" android:id="@+id/preferentialretain" android:onclick="buttony" <Button android:layout_width="wrap_content" android:text="load" android:id="@+id/preferentialrestore" android:onclick="buttony" <Button android:id="@+id/doneprefs" android:text="next!" android:onclick="buttony" </LinearLayout> As you can see, it's just a couple buttons to trigger the basic actions we'll be wanting: loading and saving. On the code side, I think I'll abstract those behaviours out into separate methods. Upon creating the Activity, I'll have it invoke the retrieval behaviour, to auto-initialize the display. We've already seen this style of retrieving data. If we want something that doesn't exist, we'll need to provide a default value. In this case, we'll be storing a String, and if it doesn't exist, we'll just go with the empty string. Finally, empty strings are boring, so our code will only display a value if it has a 'real' one.
3 Let's look at retrieving data first: private void retrieve() { //Of course, we don't normally use this for widgets! SharedPreferences memories=getpreferences(context.mode_private); //we could use getsharedpreferences if we wanted to choose the preference file //Also, 0 would have been just fine for the mode TextView display=(textview)findviewbyid(r.id.preferentialdisplay); String value=memories.getstring("somekey","");//the second term is the default value if (!value.equals("")) display.settext(value); So let's explain the pieces here: The SharedPreferences object, used this way, loads the default preferences file for the application If you want to try opening in different modes, know that many access mechanisms have been deprecated by recent versions of Android (basically, if you want to share preferences across applications, it's possible, but less pleasant) The query syntax is basically the same as our 'extras' Of course, our oncreate can just call this at the end. Next, how can we save? //It's often a good idea to attach this kind of thing to onstop private void store() { TextView entry=(edittext)findviewbyid(r.id.preferentialinput); String value=entry.gettext().tostring(); if (!value.equals("")) { SharedPreferences memories=getpreferences(context.mode_private); SharedPreferences.Editor editor=memories.edit(); editor.putstring("somekey",value); //Please don't forget this part: editor.commit(); Note that, to make changes, we need to use an Editor. And please, pretty please, don't forget to commit the changes! By now, the buttons should be trivial: public void buttony(view v) { switch (v.getid()) { case R.id.preferentialRetain: store(); break; case R.id.preferentialRestore: retrieve(); break; case R.id.donePrefs: //start next activity break;
4 Well, let's give it a try! Reminders about preferences Though our simple example obviously worked, don't forget that this is not how one would typically interact with the data in a preference file. Most commonly, there are premade Activities/Fragments for managing actual user preferences. That's why most Android applications have effectively identical designs for their user settings: because it's provided for you. Also, though I'm sure you could find a way to jury-rig them into storing arbitrary data, you really shouldn't try to move outside the paradigm of single set of key-value tuples. Storing records Okay, so we shouldn't be using preference files to store arbitrary data/records. Well, if that's what we shouldn't use, then what should we? Let's pull back from Mobile and ask the same question for any other computer: I have several records, and wish to store them in an organized fashion, that will allow for later searching, retrieval, and updates; what do I do? A database? Then I guess that's our answer here, as well! SQLite Android includes SQLite. As the name implies, SQLite is a database management system for lightweight databases. How lightweight? Well, you probably wouldn't want ot use it on a server for most tasks, but it's just spiffy for single-user operation, which makes it perfect for storing data for a single application. That's why many programs use it for storing user settings, personal data, etc. (e.g. web browsers often use it for your cookies, bookmarks, and settings). It's worth noting that, between Android and Android Studio, you're also provided with a couple more tools for managing and inspecting SQLite databases, but we don't need to worry about that today. Source of database In order to user a database, we'll of course need to have said database. Depending on your needs, you could create it completely in advance, and distribute it with your application. Alternatively, your application can build it (e.g. on the first execution). Our example will be doing the latter. Operation The operation isn't terribly difficult. Android includes an abstract SQLiteOpenHelper class to help with opening and accessing the database. Queries use a Cursor to keep track of where you are within the query results.
5 First example Let's start very small. We'd like: To create a database if we don't already have one An activity for creating a new entry An activity to let us view one piece of data Some way of removing the data Creating the database As mentioned earlier, Android includes an SQLiteOpenHelper to help you manage your databases. It actually already does nearly all of the work for you. There's just one catch: If the desired database doesn't yet exist, it needs to be able to create it. But how would it know what to create? That's where you come in. Let's create a simple Java class: public class DataHelper extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 2; public static final String DB_NAME = "sophia"; public static final String DB_TABLE = "wisdom"; public static final int DB_VERSION = 1; private static final String CREATE_TABLE = "CREATE TABLE " + DB_TABLE + " (rule INTEGER PRIMARY KEY, subject TEXT, lesson TEXT);"; DataHelper(Context context) { super(context,db_name,null,database_version); public void oncreate(sqlitedatabase db) { db.execsql(create_table); public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { //How to migrate or reconstruct data from old version to new on upgrade Note that I skipped the package/import lines. So, what's going on here? This particular database is called sophia We have a single table, wisdom Each entry under wisdom is indexed by a rule number, and has both a subject and a lesson text
6 So far, so good. We can now use that whenever we want to access the database! We're going to have three basic operations for now: adding entries, showing a single entry, and wiping out the database. In a real application, there'd be more (e.g. editing existing entries; showing multiple entries simultaneously, probably using an adapter; and deleting individual records), but this is enough to see it working. Making a new entry Let's make our first Activity, NewWisdom, and have our initial activity start it upon the button press. First, the layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_height="match_parent" tools:context="ca.brocku.efoxwell.a2017_sixthstage.newwisdom" android:orientation="vertical"> <EditText android:id="@+id/editsubject" <EditText android:id="@+id/editlesson" <Button android:text="save!" android:onclick="save" </LinearLayout> and now the Java code: public class NewWisdom extends AppCompatActivity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_new_wisdom); public void save(view v) { EditText subwidget=(edittext)findviewbyid(r.id.editsubject); EditText leswidget=(edittext)findviewbyid(r.id.editlesson); DataHelper dh=new DataHelper(this); SQLiteDatabase datachanger=dh.getwritabledatabase(); ContentValues newwisdom=new ContentValues(); newwisdom.put("subject",subwidget.gettext().tostring()); newwisdom.put("lesson",leswidget.gettext().tostring()); datachanger.insert(datahelper.db_table,null,newwisdom); datachanger.close(); //startactivity(new Intent(this,ShowWisdom.class));
7 Let's look at what's new: First, see how our DataHelper actually helps us: we use it to open the database for us. If we want to make changes, get a writable database; otherwise get a readable one The way we encapsulate field values within a record is as a ContentValues We aren't explicitly specifying the rule number here, because we'd rather SQLite handle that for us After we're done, we explicitly close the database Starting the next Activity isn't important right now. It'll just be a temporary convenience thing. Let's give it a sample run, and verify that it works. More specifically, verify that it doesn't crash for some reason. Try adding an entry or two. Viewing an entry Queries are pretty easy in SQLite. Most of you already have some experience with databases, so this should be trivial. There's one thing worth noting: when we query for a selection of records, what we'll receive will be a Cursor. In this context, a Cursor is effectively a combination of a data structure, and your position within that data structure (think: cursored lists from 1P03). If our focus were on elaborate queries, we'd cover the finer points of SQL syntax, but you already know all that, so we're going to do this the easy way: we'll query everything, and simply ignore everything that isn't the first line. Let's make a new Activity, ShowWisdom. Our layout will be as follows: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_height="match_parent" tools:context="ca.brocku.efoxwell.a2017_sixthstage.showwisdom" android:orientation="vertical"> <TextView android:id="@+id/showrule" <TextView android:id="@+id/showsubject" <TextView android:id="@+id/showlesson" <Button android:onclick="click" </LinearLayout>
8 The code will be pretty easy: public class ShowWisdom extends AppCompatActivity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_show_wisdom); query(); private void query() { String[] fields=new String[]{"rule","subject","lesson"; TextView rulwidget=(textview)findviewbyid(r.id.showrule); TextView subwidget=(textview)findviewbyid(r.id.showsubject); TextView leswidget=(textview)findviewbyid(r.id.showlesson); DataHelper dh=new DataHelper(this); SQLiteDatabase datareader=dh.getreadabledatabase(); Cursor cursor=datareader.query(datahelper.db_table,fields, null,null,null,null,null); cursor.movetofirst(); if (!cursor.isafterlast()) { rulwidget.settext(""+cursor.getint(0)); subwidget.settext(cursor.getstring(1)); leswidget.settext(cursor.getstring(2)); if (cursor!=null &&!cursor.isclosed()) cursor.close(); public void click(view v) { //startactivity(new Intent(this,BobbyTables.class)); If we did want to inspect more of the results, the Cursor can be advanced via movetonext(). You'll have good reason to look into this again very soon, so for now, ensure that you can get this simpler example working, and then work on expanding later. Deletion Selective deletion is left as an exercise for now, but let's just take a gander at the nuclear option. I had one more Activity, BobbyTables. In it, behind a confirmation button, I have this: deletedatabase(datahelper.db_name); It kills records dead. One additional observation for our 'DataHelper': note that it's very minimal. Currently, we have code for insertion in one Activity, code for viewing in another, code for deletion in another, etc. Since those are all database-related actions, it would be entirely reasonable (and normal) to shift those over into the helper class.
9 Give everything one last test, to see what's going on. It should be easy to see how readily expandable it is. This is ridiculous Yup, it is. Why? Because we keep shimmying back and forth between Activities. To say that's less than ideal would be an understatement. If we wanted to, we could easily create a single Activity to act as our primary launch point to other tasks. We could even put each of the tasks into separate Fragments. However, what we're really talking about is an application that has different modes, into which we'd like to jump. How would we normally expect to achieve something like that? Exactly: menus. (If we have time) Menus Menus are our default go-to whenever we have a multitude of things we could do, and a long strip of buttons would be a bit unwieldy. There are different usages for menus, but they mostly fall under one of the following: Options menus Or an Activity menu. This is what you typically have that's always available to you (e.g. the 'three dots' in the corner of the Activity), to let you switch into a different mode, or initiate an action within the current display Context menus When you 'long-press' an entry in Android, you'll sometimes bring up a popup menu. That's also Submenus known as a context menu. It provides actions or information, normally specific to the exact widget/entry you just long-pressed Sometimes you can't fit everything into a single menu (or simply don't want to). If you have multiple entries that all tie to the same topic, then you might wish to bundle them all up together, and have them appear as a collection of menu options, under a single entry in a parent menu It's worth noting that, depending on your API level, you may have different options, or even the same options but behaving differently. For example, the Action Bar (a special widget to replace the normal title bar) was added quite a while ago.
10 Defining a menu (Prepare for deja vu) We could use Java to programmatically generate menus, and sometimes still might if there's a specific need to warrant it, but typically we'll define the menus in XML files. The default folder for a menu is res/menu. Depending on which entry you used in Android Studio to create your Activities, you might already have this folder (along with an accompanying sample menu). If not, just create the folder. We'll create our first menu, and just call it tasks. We'll start small, and expand it later: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android=" <item android:id="@+id/menu_greet" android:title="about" android:icon="@mipmap/ic_launcher" </menu> For now, let's just deal with what we can do with our initial activity. We need to add two separate chunks of code: public boolean oncreateoptionsmenu(menu menu) { MenuInflater inflater=getmenuinflater(); inflater.inflate(r.menu.tasks,menu); return true; This tells it how to construct the options menu. Note that we're overriding the default behaviour of, don't. Next: public boolean onoptionsitemselected(menuitem item) { Toast.makeText(this,"Hello",Toast.LENGTH_SHORT).show(); return true; This tells it how to handle clicking on a menu item. Of course, after this, we'll be comparing against ids. Expanding the idea Let's make some changes: Our menu should have new options for the tasks we've already implemented I think I'd prefer a static class to handle those menu tasks We no longer need the buttons to start new activities (but still need two of them for confirmation)
11 The new menu: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android=" <item android:title="add entry" <item android:title="show entry" <item android:title="purge database" <item android:title="about" </menu> Our first change to MainActivity: public boolean onoptionsitemselected(menuitem item) { return ModeSwitcher.handleMenuClicky(item,this); ModeSwitcher.java: public class ModeSwitcher { public static boolean handlemenuclicky(menuitem item, Context from) { //Activity? switch (item.getitemid()) { case R.id.menu_new: from.startactivity(new Intent(from,NewWisdom.class)); ((Activity)from).finish(); break; case R.id.menu_show: from.startactivity(new Intent(from,ShowWisdom.class)); ((Activity)from).finish(); break; case R.id.menu_drop: from.startactivity(new Intent(from,BobbyTables.class)); ((Activity)from).finish(); break; case R.id.menu_greet: Toast.makeText(from,"Hello",Toast.LENGTH_SHORT).show(); break; return true; In case it isn't readily apparent, the reason I'm doing this one this way is because we're going to be simply copying the menu to each of the activities. Since the code's entirely redundant, I preferred to have it centralized. But you wouldn't normally have each Activity share the same options menu. Normally, options menus show tasks specific to the displayed Activity.
12 Changes to the task Activities: public boolean oncreateoptionsmenu(menu menu) { MenuInflater inflater=getmenuinflater(); inflater.inflate(r.menu.tasks,menu); return true; public boolean onoptionsitemselected(menuitem item) { return ModeSwitcher.handleMenuClicky(item,this); Of course, we just tack this onto the end of each of them. Don't forget to also remove the startactivitys from any of them that still have it. Give it a try, and see how it works. Context Menus Let's say I want to have a long press menu attached to a displayed record. If there's time, I think this might be a good excuse to finally expand on the database query slightly. Let's create one more Activity, ListWisdom. For the layout, just add a single ListView, with an id of allentries. For the code: public class ListWisdom extends AppCompatActivity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_list_wisdom); query(); private void query() { String[] fields=new String[]{"rule","subject","lesson"; ListView lv=(listview)findviewbyid(r.id.allentries); ArrayList<String> entries=new ArrayList<>(); DataHelper dh=new DataHelper(this); SQLiteDatabase datareader=dh.getreadabledatabase(); Cursor cursor=datareader.query(datahelper.db_table,fields, null,null,null,null,null); cursor.movetofirst(); while (!cursor.isafterlast()) { entries.add(integer.tostring(cursor.getint(0))+", "+ cursor.getstring(1)+", "+cursor.getstring(2)); cursor.movetonext(); if (cursor!=null &&!cursor.isclosed()) cursor.close(); ArrayAdapter<String> adapter=new ArrayAdapter<>(this, android.r.layout.simple_list_item_1,entries);
13 lv.setadapter(adapter); registerforcontextmenu(lv); datareader.close(); public void oncreatecontextmenu(contextmenu menu, View v, ContextMenu.ContextMenuInfo menuinfo) { if (v.getid()==r.id.allentries) { ListView lv=(listview) v; AdapterView.AdapterContextMenuInfo cmi= (AdapterView.AdapterContextMenuInfo) menuinfo; String entry=(string)lv.getitematposition(cmi.position); menu.setheadertitle(entry); menu.add("agree"); menu.add("disagree"); public boolean oncontextitemselected(menuitem item) { Toast.makeText(this,item.getTitle(),Toast.LENGTH_SHORT).show(); return true; public boolean oncreateoptionsmenu(menu menu) { MenuInflater inflater=getmenuinflater(); inflater.inflate(r.menu.tasks,menu); return true; public boolean onoptionsitemselected(menuitem item) { return ModeSwitcher.handleMenuClicky(item,this); Some observations: When you want a context menu, it's handled nearly identically to any other menu. The difference is that you register individual widgets for menus, instead of the Activity as a whole For the sake of comparison, this menu is programmatically created. There are a few extra nifty options, but honestly if you need anything remotely complicated, you shouldn't be creating it via the Java code We're not actually making any significant use of the selected contextual command Before testing it out, remember to actually add this new entry to the menu, and add the corresponding code to the ModeSwitcher class.
14 Submenus And, finally, submenus. Programmatically, these can be a bit of a pain, so we'll stick to XML-defined ones. Submenus in general are very simple: they're just menus within menus. There's a quirk, but it's easy to spot: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android=" xmlns:app=" > <item android:id="@+id/menu_new" android:title="add entry" <item android:title="query"> <menu> <item android:id="@+id/menu_show" android:title="show entry" <item android:id="@+id/menu_list" android:title="list all entries" </menu> </item> <item android:id="@+id/menu_drop" android:title="purge database" <item android:id="@+id/menu_greet" android:title="about" android:icon="@mipmap/ic_launcher" app:showasaction="ifroom" </menu> While we were at it, the About entry has also changed slightly. Of course, there are also additional menu options, like check boxes and such (use group, along with checkablebehavior), you can have the application icon appear in the corner for clicking, and with later API levels even more was added. But this is a good starting point. If you'd like to learn more, this is a good resource: huh... there's still space down here... Did we ever do anything about that spare button for showing a single record? Can we guess what getsupportactionbar() is for?
More Effective Layouts
More Effective Layouts In past weeks, we've looked at ways to make more effective use of the presented display (e.g. elastic layouts, and separate layouts for portrait and landscape), as well as autogenerating
More informationAdapting to Data. Before we get to the fun stuff... Initial setup
Adapting to Data So far, we've mostly been sticking with a recurring theme: visual elements are tied to XML-defined resources, not programmatic creation or management. But that won't always be the case.
More informationEventually, you'll be returned to the AVD Manager. From there, you'll see your new device.
Let's get started! Start Studio We might have a bit of work to do here Create new project Let's give it a useful name Note the traditional convention for company/package names We don't need C++ support
More informationMeniu. Create a project:
Meniu Create a project: Project name: P0131_MenuSimple Build Target: Android 2.3.3 Application name: MenuSimple Package name: ru.startandroid.develop.menusimple Create Activity: MainActivity Open MainActivity.java.
More informationAndroid Programs Day 5
Android Programs Day 5 //Android Program to demonstrate the working of Options Menu. 1. Create a New Project. 2. Write the necessary codes in the MainActivity.java to create OptionMenu. 3. Add the oncreateoptionsmenu()
More informationDatabase Development In Android Applications
ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran
More informationAn Android Studio SQLite Database Tutorial
An Android Studio SQLite Database Tutorial Previous Table of Contents Next An Android Studio TableLayout and TableRow Tutorial Understanding Android Content Providers in Android Studio Purchase the fully
More information05. RecyclerView and Styles
05. RecyclerView and Styles 08.03.2018 1 Agenda Intents Creating Lists with RecyclerView Creating Cards with CardView Application Bar Menu Styles and Themes 2 Intents 3 What is Intent? An Intent is an
More informationEng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence
Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza Data persistence Shared preferences A method to store primitive data in android as key-value pairs, these saved data will
More informationDeveloping Android Applications Introduction to Software Engineering Fall Updated 1st November 2015
Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 1st November 2015 Android Lab 3 & Midterm Additional Concepts No Class Assignment 2 Class Plan Android : Additional
More informationSpring Lecture 5 Lecturer: Omid Jafarinezhad
Mobile Programming Sharif University of Technology Spring 2016 - Lecture 5 Lecturer: Omid Jafarinezhad Storage Options Android provides several options for you to save persistent application data. The
More information07. Data Storage
07. Data Storage 22.03.2018 1 Agenda Data storage options How to store data in key-value pairs How to store structured data in a relational database 2 Data Storage Options Shared Preferences Store private
More informationAndroid Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)
Android Specifics Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics ArrayAdapter Preferences Widgets Jonathan Diehl, Hendrik Thüs 2 ArrayAdapter Jonathan Diehl, Hendrik Thüs
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should
More informationResources and Media and Dealies
Resources and Media and Dealies In the second week, we created a new project that came with several files. The layout was kept in a res/layout folder. last week, we looked at a landscape layout, in the
More informationLayout and Containers
Geez, that title is freakin' huge. Layout and Containers This week, we'll mostly just be looking at how to better-arrange elements. That will include our first introduction into managed resources (even
More informationThe Stack, Free Store, and Global Namespace
Pointers This tutorial is my attempt at clarifying pointers for anyone still confused about them. Pointers are notoriously hard to grasp, so I thought I'd take a shot at explaining them. The more information
More informationAndroid Using Menus. Victor Matos Cleveland State University
Lesson 8 Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9 & Android Developers http://developer.android.com/index.html
More informationGetting Started With Android Feature Flags
Guide Getting Started With Android Feature Flags INTRO When it comes to getting started with feature flags (Android feature flags or just in general), you have to understand that there are degrees of feature
More informationMobile and Ubiquitous Computing: Android Programming (part 4)
Mobile and Ubiquitous Computing: Android Programming (part 4) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Examples from: Mobile and Ubiquitous Computing Jo Vermeulen,
More informationMITOCW watch?v=rvrkt-jxvko
MITOCW watch?v=rvrkt-jxvko The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationCOSC 3P97 Assignment 1
Due: Oct. 12 @ 5:00 pm. COSC 3P97 Assignment 1 Fall 2018/19 Create a new Android Studio project or Eclipse workspace for the assignment. The app should run on API 23 (Marshmallow). Calculator Write an
More informationMobile Programming Lecture 10. ContentProviders
Mobile Programming Lecture 10 ContentProviders Lecture 9 Review In creating a bound service, why would you choose to use a Messenger over extending Binder? What are the differences between using GPS provider
More informationOur First Android Application
Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,
More informationVienos veiklos būsena. Theory
Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is
More informationPROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between
MITOCW Lecture 10A [MUSIC PLAYING] PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between all these high-level languages like Lisp and the query
More informationLesson 3 Transcript: Part 1 of 2 - Tools & Scripting
Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Slide 1: Cover Welcome to lesson 3 of the db2 on Campus lecture series. Today we're going to talk about tools and scripting, and this is part 1 of 2
More informationAndroid Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop
Workshop 1. Create an Option Menu, and convert it into Action Bar (Page 1 8) Create an simple Option Menu Convert Option Menu into Action Bar Create Event Listener for Menu and Action Bar Add System Icon
More informationMobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences
Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences Agenda Dialogs Menus SharedPreferences Android Application Components 1. Activity 2. Broadcast Receiver 3. Content Provider 4. Service
More informationMobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling
Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling Lecture 1 Review How to edit XML files in Android Studio? What holds all elements (Views) that appear to the user in an Activity?
More informationPost Experiment Interview Questions
Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid
More informationStarting Another Activity Preferences
Starting Another Activity Preferences Android Application Development Training Xorsat Pvt. Ltd www.xorsat.net fb.com/xorsat.education Outline Starting Another Activity Respond to the Button Create the
More informationArrays of Buttons. Inside Android
Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.
More informationDebojyoti Jana (Roll ) Rajrupa Ghosh (Roll ) Sreya Sengupta (Roll )
DINABANDHU ANDREWS INSTITUTE OF TECHNOLOGY AND MANAGEMENT (Affiliated to West Bengal University of Technology also known as Maulana Abul Kalam Azad University Of Technology) Project report on ANDROID QUIZ
More informationMobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.
Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New
More informationMITOCW watch?v=0jljzrnhwoi
MITOCW watch?v=0jljzrnhwoi The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu India Summer 2012 Review Session Android and Web Working with Views Working with Views Create a new Android project. The app name should
More informationApplied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)
Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) In this exercise, we will create a simple Android application that uses IBM Bluemix Cloudant NoSQL DB. The application
More informationMobila applikationer och trådlösa nät, HI1033, HT2012
Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android
More informationUsing the API: Introductory Graphics Java Programming 1 Lesson 8
Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using Java Provided Classes In this lesson we'll focus on using the Graphics class and its capabilities. This will serve two purposes: first
More informationSo on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees.
So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees. According to the 161 schedule, heaps were last week, hashing
More informationPROFESSOR: Well, yesterday we learned a bit about symbolic manipulation, and we wrote a rather stylized
MITOCW Lecture 4A PROFESSOR: Well, yesterday we learned a bit about symbolic manipulation, and we wrote a rather stylized program to implement a pile of calculus rule from the calculus book. Here on the
More informationMYOB Exo PC Clock. User Guide
MYOB Exo PC Clock User Guide 2018.01 Table of Contents Introduction to MYOB Exo PC Clock... 1 Installation & Setup... 2 Server-based... 2 Standalone... 3 Using Exo PC Clock... 4 Clocking Times... 5 Updating
More informationAndroid Using Menus. Victor Matos Cleveland State University
8 Android Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9 & Android Developers http://developer.android.com/index.html
More information10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics
Chapter 10 Speech Recognition 10.1 Introduction Speech recognition (SR) by machine, which translates spoken words into text has been a goal of research for more than six decades. It is also known as automatic
More informationIntents. Your first app assignment
Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work
More informationMobile Computing Practice # 2c Android Applications - Interface
Mobile Computing Practice # 2c Android Applications - Interface One more step in the restaurants application. 1. Design an alternative layout for showing up in landscape mode. Our current layout is not
More informationJava Programming Constructs Java Programming 2 Lesson 1
Java Programming Constructs Java Programming 2 Lesson 1 Course Objectives Welcome to OST's Java 2 course! In this course, you'll learn more in-depth concepts and syntax of the Java Programming language.
More informationIt Might Be Valid, But It's Still Wrong Paul Maskens and Andy Kramek
Seite 1 von 5 Issue Date: FoxTalk July 2000 It Might Be Valid, But It's Still Wrong Paul Maskens and Andy Kramek This month, Paul Maskens and Andy Kramek discuss the problems of validating data entry.
More informationArduino IDE Friday, 26 October 2018
Arduino IDE Friday, 26 October 2018 12:38 PM Looking Under The Hood Of The Arduino IDE FIND THE ARDUINO IDE DOWNLOAD First, jump on the internet with your favorite browser, and navigate to www.arduino.cc.
More informationAzon Master Class. By Ryan Stevenson Guidebook #5 WordPress Usage
Azon Master Class By Ryan Stevenson https://ryanstevensonplugins.com/ Guidebook #5 WordPress Usage Table of Contents 1. Widget Setup & Usage 2. WordPress Menu System 3. Categories, Posts & Tags 4. WordPress
More informationAssignment 1: grid. Due November 20, 11:59 PM Introduction
CS106L Fall 2008 Handout #19 November 5, 2008 Assignment 1: grid Due November 20, 11:59 PM Introduction The STL container classes encompass a wide selection of associative and sequence containers. However,
More informationMobile Computing Practice # 2d Android Applications Local DB
Mobile Computing Practice # 2d Android Applications Local DB In this installment we will add persistent storage to the restaurants application. For that, we will create a database with a table for holding
More informationAgenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen
Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing
More informationSQLite Database. References. Overview. Structured Databases
SQLite Database References Android Developers Article https://developer.android.com/training/basics/data-storage/databases.html Android SQLite Package Reference https://developer.android.com/reference/android/database/sqlite/package-summary.html
More informationActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { }
Android ActionBar import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { Layout, activity.xml
More informationHave a development environment in 256 or 255 Be familiar with the application lifecycle
Upcoming Assignments Readings: Chapter 4 by today Horizontal Prototype due Friday, January 22 Quiz 2 today at 2:40pm Lab Quiz next Friday during lecture time (2:10-3pm) Have a development environment in
More informationMobila applikationer och trådlösa nät, HI1033, HT2013
Mobila applikationer och trådlösa nät, HI1033, HT2013 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android
More informationContents. What's New. Version released. Newsletter #31 (May 24, 2008) What's New New version released, version 4.3.3
Campground Master Newsletter #31 (May 24, 2008) 1 Newsletter #31 (May 24, 2008) Contents What's New New version released, version 4.3.3 Q & A Retrieving credit card information Guarantee Info missing the
More informationMITOCW watch?v=kz7jjltq9r4
MITOCW watch?v=kz7jjltq9r4 PROFESSOR: We're going to look at the most fundamental of all mathematical data types, namely sets, and let's begin with the definitions. So informally, a set is a collection
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are
More informationIn our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.
Guide to and Hi everybody! In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. This guide focuses on two of those symbols: and. These symbols represent concepts
More informationInstructor: Craig Duckett. Lecture 04: Thursday, April 5, Relationships
Instructor: Craig Duckett Lecture 04: Thursday, April 5, 2018 Relationships 1 Assignment 1 is due NEXT LECTURE 5, Tuesday, April 10 th in StudentTracker by MIDNIGHT MID-TERM EXAM is LECTURE 10, Tuesday,
More informationmk-convert Contents 1 Converting to minikanren, quasimatically. 08 July 2014
mk-convert 08 July 2014 Contents 1 Converting to minikanren, quasimatically. 1 1.1 Variations on a Scheme..................... 2 1.2 Racket to minikanren, nally.................. 8 1.3 Back to the beginning......................
More informationCSCU9YH: Development with Android
: Development with Android Computing Science and Mathematics University of Stirling Data Storage and Exchange 1 Preferences: Data Storage Options a lightweight mechanism to store and retrieve keyvalue
More informationHi everyone. Starting this week I'm going to make a couple tweaks to how section is run. The first thing is that I'm going to go over all the slides
Hi everyone. Starting this week I'm going to make a couple tweaks to how section is run. The first thing is that I'm going to go over all the slides for both problems first, and let you guys code them
More informationMITOCW watch?v=zm5mw5nkzjg
MITOCW watch?v=zm5mw5nkzjg The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationBEGINNER PHP Table of Contents
Table of Contents 4 5 6 7 8 9 0 Introduction Getting Setup Your first PHP webpage Working with text Talking to the user Comparison & If statements If & Else Cleaning up the game Remembering values Finishing
More informationAndroid App Development. Mr. Michaud ICE Programs Georgia Institute of Technology
Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based
More informationUpon completion of the second part of the lab the students will have:
ETSN05, Fall 2017, Version 2.0 Software Development of Large Systems Lab 2 1. INTRODUCTION The goal of lab 2 is to introduce students to the basics of Android development and help them to create a starting
More informationHello, and welcome to another episode of. Getting the Most Out of IBM U2. This is Kenny Brunel, and
Hello, and welcome to another episode of Getting the Most Out of IBM U2. This is Kenny Brunel, and I'm your host for today's episode which introduces wintegrate version 6.1. First of all, I've got a guest
More informationContents. What's New. Dropbox / OneDrive / Google drive Warning! A couple quick reminders:
Campground Master Contents 1 Contents A couple quick reminders: Make Backups! It's so sad when we hear from someone whose computer has crashed and they have no backup of their data to restore from. It's
More informationData Persistence. Chapter 10
Chapter 10 Data Persistence When applications create or capture data from user inputs, those data will only be available during the lifetime of the application. You only have access to that data as long
More informationAndroid Data Storage
Lesson 14 Android Persistency: Victor Matos Cleveland State University Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9
More informationSoftware Engineering Large Practical: Storage, Settings and Layouts. Stephen Gilmore School of Informatics October 27, 2017
Software Engineering Large Practical: Storage, Settings and Layouts Stephen Gilmore School of Informatics October 27, 2017 Contents 1. Storing information 2. Settings 3. Layouts 1 Storing information Storage
More informationLab 1 - Setting up the User s Profile UI
Lab 1 - Setting up the User s Profile UI Getting started This is the first in a series of labs that allow you to develop the MyRuns App. The goal of the app is to capture and display (using maps) walks
More informationFormal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5
Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 [talking head] This lecture we study theory design and implementation. Programmers have two roles to play here. In one role, they
More informationCS 4330/5390: Mobile Application Development Exam 1
1 Spring 2017 (Thursday, March 9) Name: CS 4330/5390: Mobile Application Development Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and closed-book.
More informationChrome if I want to. What that should do, is have my specifications run against four different instances of Chrome, in parallel.
Hi. I'm Prateek Baheti. I'm a developer at ThoughtWorks. I'm currently the tech lead on Mingle, which is a project management tool that ThoughtWorks builds. I work in Balor, which is where India's best
More informationMITOCW MIT6_01SC_rec2_300k.mp4
MITOCW MIT6_01SC_rec2_300k.mp4 KENDRA PUGH: Hi. I'd like to talk to you today about inheritance as a fundamental concept in object oriented programming, its use in Python, and also tips and tricks for
More informationMobile Programming Lecture 5. Composite Views, Activities, Intents and Filters
Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters Lecture 4 Review How do you get the value of a string in the strings.xml file? What are the steps to populate a Spinner or
More informationHi everyone. I hope everyone had a good Fourth of July. Today we're going to be covering graph search. Now, whenever we bring up graph algorithms, we
Hi everyone. I hope everyone had a good Fourth of July. Today we're going to be covering graph search. Now, whenever we bring up graph algorithms, we have to talk about the way in which we represent the
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationExternal Services. CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion
External Services CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion 1 External Services Viewing websites Location- and map-based functionality
More informationGrocery List: An Android Application
The University of Akron IdeaExchange@UAkron Honors Research Projects The Dr. Gary B. and Pamela S. Williams Honors College Spring 2018 Grocery List: An Android Application Daniel McFadden djm188@zips.uakron.edu
More informationP1_L3 Operating Systems Security Page 1
P1_L3 Operating Systems Security Page 1 that is done by the operating system. systems. The operating system plays a really critical role in protecting resources in a computer system. Resources such as
More informationClass #7 Guidebook Page Expansion. By Ryan Stevenson
Class #7 Guidebook Page Expansion By Ryan Stevenson Table of Contents 1. Class Purpose 2. Expansion Overview 3. Structure Changes 4. Traffic Funnel 5. Page Updates 6. Advertising Updates 7. Prepare for
More informationWhat's New. Version 9.2 release. Campground Master Contents 1. Contents. A couple quick reminders:
Campground Master Contents 1 Contents A couple quick reminders: Make Backups! It's so sad when we hear from someone whose computer has crashed and they have no backup of their data to restore from. It's
More informationMobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09
Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Hello, today we will create another application called a math quiz. This
More informationCreate Parent Activity and pass its information to Child Activity using Intents.
Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu;
More informationCasting in C++ (intermediate level)
1 of 5 10/5/2009 1:14 PM Casting in C++ (intermediate level) Casting isn't usually necessary in student-level C++ code, but understanding why it's needed and the restrictions involved can help widen one's
More informationSQLite. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases. What is a Database Server. Advantages of SQLite
SQLite 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases Dr Dimitris C. Dracopoulos SQLite is a tiny yet powerful database engine. Besides Android, it can be found in: Apple iphone
More informationFormal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5
Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 [talking head] Formal Methods of Software Engineering means the use of mathematics as an aid to writing programs. Before we can
More informationThis Week on developerworks Push for ios, XQuery, Spark, CoffeeScript, top Rational content Episode date:
This Week on developerworks Push for ios, XQuery, Spark, CoffeeScript, top Rational content Episode date: 02-15-2012 [ MUSIC ] LANINGHAM: Welcome to this week on developerworks. I'm Scott Laningham in
More informationLinked Lists. What is a Linked List?
Linked Lists Along with arrays, linked lists form the basis for pretty much every other data stucture out there. This makes learning and understand linked lists very important. They are also usually the
More informationBlitz2D Newbies: Definitive Guide to Types by MutteringGoblin
Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin Types are probably the hardest thing to understand about Blitz Basic. If you're using types for the first time, you've probably got an uneasy
More informationAndroid Navigation Drawer for Sliding Menu / Sidebar
Android Navigation Drawer for Sliding Menu / Sidebar by Kapil - Tuesday, December 15, 2015 http://www.androidtutorialpoint.com/material-design/android-navigation-drawer-for-sliding-menusidebar/ YouTube
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationAndroid Programming Family Fun Day using AppInventor
Android Programming Family Fun Day using AppInventor Table of Contents A step-by-step guide to making a simple app...2 Getting your app running on the emulator...9 Getting your app onto your phone or tablet...10
More information