Reactive Android Development

Slides:



Advertisements
Similar presentations
Programming with Android: Data management
Advertisements

CE881: Mobile and Social Application Programming Flexible Data Handling with Integrity: SQLite Simon M. Lucas.
SQLite is a software library. It is: self-contained + Serverless + zero-configuration transactional = SQL database engine. Most widely deployed. The source.
 data/data-storage.html#pref data/data-storage.html#pref 
SQLite in Mobile Apps by Dan Youberg. Overview Many well known applications and Internet browsers use SQLite due to its very small size (~250 Kb). Also.
CONTENT PROVIDER. Content Provider  A content provider makes a specific set of the application's data available to other applications => Share data to.
Cosc 5/4730 Android and Blackberry SQLite. For the sql language syntax, please see SQlite documentation –
SQLLite and Java CS-328 Dick Steflik. SQLLite Embedded RDBMS ACID Compliant Size – about 257 Kbytes Not a client/server architecture –Accessed via function.
CS378 - Mobile Computing Persistence - SQLite. Databases RDBMS – relational data base management system Relational databases introduced by E. F. Codd.
Data Persistence in Android
SQLite Database. SQLite Public domain database – Advantages Small (about 150 KB) – Used on devices with limited resources Each database contained within.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Data Storage: Part 4 (Content Providers). Content Providers Content providers allow the sharing of data between applications. Inter-process communication.
COMP 365 Android Development.  Manages access from a central database  Allows multiple applications to access the same data.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
CS378 - Mobile Computing Persistence. Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed.
SQLite Android Club SQLite About onCreate Insert Select Update Delete onUpdate.
9 Persistence - SQLite CSNB544 Mobile Application Development Thanks to Utexas Austin.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Persistence Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
SQLite (part deux) 1 CS440. Traditional Model View Controller (MVC) CS440 2.
Mobile Software Development ISCG 7424 Department of Computing UNITEC John Casey and Richard Rabeder SQLite and Permissions.
SQLite DB Storing Data in Android RAVI GAURAV PANDEY 1.
Android - SQLite Database 12/10/2015. Introduction SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with.
SQlite. SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation.
1 CS 430 Database Theory Winter 2005 Lecture 13: SQL DML - Modifying Data.
Address Book App 1 Fall 2014 CS7020: Game Design and Development.
CHAPTER 9 File Storage Shared Preferences SQLite.
By: Eliav Menachi.  On Android, all application data (including files) are private to that application  Android provides a standard way for an application.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Data Storage in Android Димитър Н. Димитров. Why talk about data? Why not 3D graphics or network connectivity? Data as fundamental term in computer science.
CS371m - Mobile Computing Persistence - SQLite. 2 In case you have not taken 347: Data Management or worked with databases as part of a job, internship,
1 Adding a Model. We have created an MVC web app project Added a controller class. Added a view class. Next we will add some classes for managing movies.
CS499 – Mobile Application Development
Making content providers
Data Storage: Part 3 (SQLite)
Database Access with SQL
Cosc 5/4730 Sqlite primer.
Android Content Providers & SQLite
Content Providers And Content Resolvers
SQLite in Android Landon Cox March 2, 2017.
Mobile Software Development for Android - I397
Tables and Triggers.
Mobile Application Development BSCS-7 Lecture # 18, 19
Android Application SQLite 1.
CS499 – Mobile Application Development
Android Database using SQLite
Android 4: Saving Data Kirk Scott.
Mobile Application Development Chapter 5 [Persistent Data in Android]
Android 18: Saving Data Kirk Scott.
SQL – Application Persistence Design Patterns
Mobile Computing With Android ACST Android Database Storage Part 2
Reactive Android Development
CMPE419 Mobile Application Development
CS371m - Mobile Computing Persistence - SQLite.
Developing a Model-View-Controller Component for Joomla Part 3
CMPE419 Mobile Application Development
Mobile Computing With Android ACST 4550 Android Database Storage
Testing, debugging, and using support libraries
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
Android Developer Fundamentals V2
ListView A view that shows items in a vertically scrolling list. The items come from the ListAdapter associated with this view. ListAdapter is used to.
Department of School of Computing and Engineering
SQLLite and Android.
Mobile Programming Dr. Mohsin Ali Memon.
SQL – Application Persistence Design Patterns
CS122 Using Relational Databases and SQL
Presentation transcript:

Reactive Android Development CS 4593-02T & CS 5463-01T Summer 2016

Logging Logging

Logging Found in android.util.Log Provides different logging levels in the form of different methods: Log.v – verbose Log.d – debug Log.i – info Log.w – warning Log.e – error Each takes a tag and a message and can optionally take an exception instance as a third argument. Also provides wtf (what a terrible failure) methods for conditions that should never happen. Depending on configuration, this may kill the app.

Persistence Again Last time, we introduced SharedPreferences Key-Value store An app can have several named stores Acquired by either getPreferences(mode) or getSharedPreferences(filename, mode) Read with preferences.getString(key) preferences.getInt(key), etc. Written with preference.edit().putString(key,value), etc.

More Persistence (Files) Internal or External Storage External used to refer to removable storage Now, might be another internal-storage partition But there are always two External storage may not be available Writing to external storage requires permissions <manifest ...> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> ... </manifest>

More Persistence (Files) Internal Storage getFilesDir() Returns the location for storing permanent files getCacheDir() Returns the location for storing temporary cache files They may be deleted without warning if storage runs low

More Persistence (Files) External Storage Public files Other apps can read/write Will not be deleted automatically when uninstalling the app getExternalStoragePublicDirectory() Private files Technically accessible to other apps Will be automatically deleted when uninstalling the app getExternalFilesDirectory()

Structured Persistence (SQL) Recommended: Contract class public final class FeedReaderContract { // To prevent someone from accidentally instantiating the contract class, // give it an empty constructor. public FeedReaderContract() {} /* Inner class that defines the table contents */ public static abstract class FeedEntry implements BaseColumns { public static final String TABLE_NAME = "entry"; public static final String COLUMN_NAME_ENTRY_ID = "entryid"; public static final String COLUMN_NAME_TITLE = "title"; public static final String COLUMN_NAME_SUBTITLE = "subtitle"; ... }

Structured Persistence (Creation) private static final String TEXT_TYPE = " TEXT"; private static final String COMMA_SEP = ","; private static final String SQL_CREATE_ENTRIES = "CREATE TABLE " + FeedEntry.TABLE_NAME + " (" + FeedEntry._ID + " INTEGER PRIMARY KEY," + FeedEntry.COLUMN_NAME_ENTRY_ID + TEXT_TYPE + COMMA_SEP + FeedEntry.COLUMN_NAME_TITLE + TEXT_TYPE + COMMA_SEP + ... // Any other options for the CREATE command " )"; private static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS " + FeedEntry.TABLE_NAME;

Structured Persistence (Creation) public class FeedReaderDbHelper extends SQLiteOpenHelper { // If you change the database schema, you must increment the database version. public static final int DATABASE_VERSION = 1; public static final String DATABASE_NAME = "FeedReader.db"; public FeedReaderDbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } public void onCreate(SQLiteDatabase db) { db.execSQL(SQL_CREATE_ENTRIES); } public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // This database is only a cache for online data, so its upgrade policy is // to simply to discard the data and start over db.execSQL(SQL_DELETE_ENTRIES); onCreate(db); } public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { onUpgrade(db, oldVersion, newVersion);

Structured Persistence (Insertion) SQLiteDatabase db = mDbHelper.getWritableDatabase(); // Create a new map of values, where column names are the keys ContentValues values = new ContentValues(); values.put(FeedEntry.COLUMN_NAME_ENTRY_ID, id); values.put(FeedEntry.COLUMN_NAME_TITLE, title); values.put(FeedEntry.COLUMN_NAME_CONTENT, content); // Insert the new row, returning the primary key value of the new row long newRowId; newRowId = db.insert( FeedEntry.TABLE_NAME, FeedEntry.COLUMN_NAME_NULLABLE, values);

Structured Persistence (Query) SQLiteDatabase db = mDbHelper.getReadableDatabase(); // Define a projection that specifies which columns from the database // you will actually use after this query. String[] projection = { FeedEntry._ID, FeedEntry.COLUMN_NAME_TITLE, FeedEntry.COLUMN_NAME_UPDATED, ... }; // How you want the results sorted in the resulting Cursor String sortOrder = FeedEntry.COLUMN_NAME_UPDATED + " DESC"; Cursor c = db.query( FeedEntry.TABLE_NAME, // The table to query projection, // The columns to return selection, // The columns for the WHERE clause selectionArgs,//The values for the WHERE clause null, // don't group the rows null, // don't filter by row groups sortOrder // The sort order );

Fragments

Fragments Can be declared in the XML for an activity Or added dynamically (in the Activity's onCreate method) Can also be replaced at runtime in response to user input The change can be registered so that the back button still works!

Fragment communication Fragments must be associated with an Activity Delivered by the onAttach(Activity activity) method All outgoing messages should be sent to the activity rather than communicating with other fragments directly.

Fixing a messy repository mkdir MyFirstApp For all files <f> that were at the base level git mv <f> MyFirstApp git commit It will ask you for a comment (usually by opening vim, but sometimes nano) You can also use 'git commit –m "message"' git push

About git tags Tags are a way of marking a specific point in your development for future reference. You can create one with your current content with git tag –a <tagname> -m "<message>" You can create one for an old version with the checksum for its commit Git tag –a <tagname> <checksum> -m "<message>"

Suggestions from Students The following slides contain suggestions about places to get additional training and tools that might help with development

slidenerd Android tutorial reference

GenyMotion Compatible? With monkey runner.