Time for action – saving references to Objects in native Store
- Create a new Java class
com.packtpub.store.Color
encapsulating an integer representation of a color. This integer is parsed fromString
containing HTML code (for example,#FF0000
) thanks to theandroid.graphics.Color
class:package com.packtpub.store; import android.text.TextUtils; public class Color { private int mColor; public Color(String pColor) { if (TextUtils.isEmpty(pColor)) { throw new IllegalArgumentException(); } mColor = android.graphics.Color.parseColor(pColor); } @Override public String toString() { return String.format("#%06X", mColor); } }
- In
StoreType.java
, append the new Color data type to the enumeration:public enum StoreType { Integer, String, Color }
- In the
Store ...
Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.