Back to project page ingress-key-counter.
The source code is released under:
MIT License
If you think the Android project ingress-key-counter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package de.lehrbaum.keycounter; //from www .j a v a 2 s .co m import android.content.Context; import android.database.Cursor; import android.util.Log; public class Category { private static final String TAG = Category.class .getCanonicalName(); private final int id; private String name; public Category(Context context, String name) { DatabaseHandler dh = new DatabaseHandler(context); id = dh.addCategory(name); if (id < 0) { Log.d(Category.TAG, "Could not add Category: " + name); return;//something went wrong } this.name = name; } public Category(Cursor c) { id = c.getInt(0); name = c.getString(1); } /** * @return the unique id of the category */ public int getId() { return id; } /** * @return the name of the category. */ public String getName() { return name; } @Override public String toString() { return name; } public void delete(Context c) { DatabaseHandler dh = new DatabaseHandler(c); dh.deleteCategory(id); } @Override public boolean equals(Object o) { if (o instanceof Category) { return ((Category) o).id == id; } return false; } }