public GestureLibrary(String gestureDBName, Context ctx) { /* * Initialize the gesture library * * gestureTB / tableName can be null for now * * --> TODO Feature * */ Log.d("GestureLibrary(init)", "initializing Gesture Library"); // initialize db adapter myDBAdapter = new GestureLibraryDBAdapter(ctx, DEFAULT_GESTURE_TABLE); // get all the gestures from the db myGestureMap = myDBAdapter.getAllGesturesInDB(); if (DEBUG) { Log.d("GestureLibrary", "opened DB, listing some stats"); // generate some debug info printInfo("GestureLibrary"); } GLibrarySingleInstance = this; }
public boolean removeAllGesturesFromLibrary() { if (myDBAdapter != null) { if (myDBAdapter.resetDatabase()) { // get all the gestures from the db myGestureMap = myDBAdapter.getAllGesturesInDB(); if (DEBUG) { Log.d("GestureLibrary", "reset and opened DB, listing some stats"); // generate some debug info printInfo("GestureLibrary"); } return true; } else { return true; } } else { return false; } }
public void onApplicationStop() { /* * * Close the ptr to the gesture DB * * */ myDBAdapter.closeDB(); }
public void addGesture(String id, Gesture g, boolean addtoDB) { // verify if the gesture ID exits if (myGestureMap.containsKey(id)) { myGestureMap.get(id).add(g); } else { ArrayList<Gesture> gl = new ArrayList<Gesture>(10); gl.add(g); myGestureMap.put(id, gl); } if (DEBUG) { Log.i("addGesture", "attempting to insert to database"); } myDBAdapter.insertGestureToDB(g); if (DEBUG) { this.printInfo("addGesture"); } }