Back to project page donatello-y-raphael.
The source code is released under:
MIT License
If you think the Android project donatello-y-raphael 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 com.example.ATracePath; //from www. j ava 2 s . c o m import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.util.Log; /** * Created by ranrath on 22/09/14. */ public class ProgressAdapter { private SQLiteDatabase db; private DbHelper dbHelper; private Context context; public ProgressAdapter(Context context) { this.context = context; } private ProgressAdapter openToRead() { dbHelper = new DbHelper(context); db = dbHelper.getReadableDatabase(); return this; } private ProgressAdapter openToWrite() { dbHelper = new DbHelper(context); db = dbHelper.getWritableDatabase(); return this; } private void close() { db.close(); } public long insertBoard(int puzzleId, int packId, int challengeId) { String[] cols = DbHelper.TableProgressColumns; ContentValues values = new ContentValues(); values.put(cols[1], puzzleId); values.put(cols[2], packId); values.put(cols[3], challengeId); values.put(cols[4], true); openToWrite(); long value = db.insert(DbHelper.TableProgress, null, values); close(); return value; } public boolean getBoardById(int puzzleID, int packID, int challengeID) { String[] cols = DbHelper.TableProgressColumns; openToRead(); String query = cols[1] + "=" + puzzleID + " AND " + cols[2] + "=" + packID + " AND " + cols[3] + "=" + challengeID; Cursor cursor = db.query(DbHelper.TableProgress, cols, query, null, null, null, null); int results = cursor.getCount(); close(); return results == 0 ? false : true; } public long resetProgress() { openToWrite(); long value = db.delete(DbHelper.TableProgress, "1", null); close(); return value; } }