· 8 years ago · Dec 21, 2017, 10:58 AM
1package com.digitaltruth.mdc;
2
3import org.json.JSONObject;
4
5import android.content.Context;
6import android.database.Cursor;
7import android.database.SQLException;
8import android.database.sqlite.SQLiteDatabase;
9import android.database.sqlite.SQLiteOpenHelper;
10import android.util.Log;
11
12public class favDBAdapter {
13 private static final String DATABASE_NAME = "mdcFavs.db";
14 private static int DATABASE_VERSION = 106;
15 private final Context context;
16 private DatabaseHelper DBHelper;
17 private SQLiteDatabase favDB;
18
19 public favDBAdapter(Context ctx) {
20 this.context = ctx;
21 DBHelper = new DatabaseHelper(context);
22 }
23
24 private static class DatabaseHelper extends SQLiteOpenHelper {
25 DatabaseHelper(Context context) {
26 super(context, DATABASE_NAME, null, DATABASE_VERSION);
27 }
28
29 @Override
30 public void onCreate(SQLiteDatabase db) {
31 // TEMP CODE HERE
32 Log.w("RUNNING:", "ON CREATE!");
33
34 // create initial table
35 db.execSQL("CREATE TABLE tblFavTimes (_id int, favName text, filmName text, filmISO string, filmType int, devName text, devDilution text, devVolume int, devTempInC double, devTimeA int, devTimeB double, stopBathTime int, fixingTimeA int, fixingTimeB int, hypoClearTime int, rinsingTime int, photoFloTime int, agitationStart int, agitationAfter int, agitationRepeat int, notesTitle text null, notesBody text null, tempTimeConv int NOT NULL DEFAULT 0)");
36
37 // TEMP CODE HERE
38 // db.execSQL("INSERT INTO tblFavTimes ('_id', 'favName', 'filmName', 'filmISO', 'filmType', 'devName', 'devDilution', 'devVolume', 'devTempInC', 'devTimeA', 'devTimeB', 'stopBathTime', 'fixingTimeA', 'fixingTimeB', 'hypoClearTime', 'rinsingTime', 'photoFloTime', 'agitationStart', 'agitationAfter' , 'agitationRepeat', 'notesTitle', 'notesBody') VALUES(1, 'My Fav Name', 'My Film Name', '100', 0, 'My Developer Name', 'stock', 10, 20, 10, 10, 10, 10, 5, 4, 5, 6, 1, 3, 1, 'My Notes Title', 'My Notes Body')");
39 }
40
41 @Override
42 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
43 // Alter Fav table to add new column for temptimeconversion
44 // db.execSQL("ALTER TABLE tblFavTimes ADD COLUMN tempTimeConv INTEGER NOT NULL DEFAULT 0");
45
46 /*
47 * // Clear old table out of DB
48 * db.execSQL("DROP TABLE IF EXISTS tblFavTimes");
49 *
50 * // Recreate table with correct fields db.execSQL(
51 * "CREATE TABLE tblFavTimes (_id int, favName text, filmName text, filmISO string, filmType int, devName text, devDilution text, devVolume int, devTempInC double, devTimeA int, devTimeB double, stopBathTime int, fixingTimeA int, fixingTimeB int, hypoClearTime int, rinsingTime int, photoFloTime int, agitationStart int, agitationAfter int, agitationRepeat int, notesTitle text null, notesBody text null, tempTimeConv int NOT NULL DEFAULT 0)"
52 * );
53 */
54
55 // this.onCreate(this.getWritableDatabase());
56
57 Log.w("RUNNING:", "ON UPGRADE!");
58
59 boolean foundColumn = false;
60
61 // Check to see if table has tempTimeConv field
62 Cursor ti = db.rawQuery("PRAGMA table_info(tblFavTimes)", null);
63 if (ti.moveToFirst()) {
64 do {
65 if (ti.getString(1).equals("tempTimeConv")) {
66 foundColumn = true;
67 // Log.w("Status", "Found it");
68 }
69 // Log.w("col: ", ti.getString(1));
70 } while (ti.moveToNext());
71 }
72
73 // If column wasn't found --> copy data in existing table to temp
74 // table, drop table, recreate table with column, and copy data back
75 if (foundColumn == false) {
76 // Create new temp table
77 db.execSQL("CREATE TABLE tblFavTimesTEMP (_id int, favName text, filmName text, filmISO string, filmType int, devName text, devDilution text, devVolume int, devTempInC double, devTimeA int, devTimeB double, stopBathTime int, fixingTimeA int, fixingTimeB int, hypoClearTime int, rinsingTime int, photoFloTime int, agitationStart int, agitationAfter int, agitationRepeat int, notesTitle text null, notesBody text null, tempTimeConv int NOT NULL DEFAULT 0)");
78
79 Cursor c;
80 c = db.rawQuery("SELECT * FROM tblFavTimes ORDER BY _id ASC", null);
81
82 // Get data from old table and copy to temp table
83 c.moveToFirst();
84 if (!c.isAfterLast()) {
85 while (!c.isAfterLast()) {
86 db.execSQL("INSERT INTO tblFavTimesTEMP ('_id', 'favName', 'filmName', 'filmISO', 'filmType', 'devName', 'devDilution', 'devVolume', 'devTempInC', 'devTimeA', 'devTimeB', 'stopBathTime', 'fixingTimeA', 'fixingTimeB', 'hypoClearTime', 'rinsingTime', 'photoFloTime', 'agitationStart', 'agitationAfter' , 'agitationRepeat', 'notesTitle', 'notesBody', 'tempTimeConv') VALUES("
87 + c.getString(0)
88 + ", '"
89 + c.getString(1)
90 + "', '"
91 + c.getString(2)
92 + "',"
93 + c.getString(3)
94 + ","
95 + c.getString(4)
96 + ", '"
97 + c.getString(5)
98 + "', '"
99 + c.getString(6)
100 + "', "
101 + c.getString(7)
102 + ","
103 + c.getString(8)
104 + ","
105 + c.getString(9)
106 + ","
107 + c.getString(10)
108 + ","
109 + c.getString(11)
110 + ","
111 + c.getString(12)
112 + ","
113 + c.getString(13)
114 + ","
115 + c.getString(14)
116 + ","
117 + c.getString(15)
118 + ","
119 + c.getString(16)
120 + ","
121 + c.getString(17)
122 + ","
123 + c.getString(18)
124 + ","
125 + c.getString(19)
126 + ",'"
127 + c.getString(20) + "', '" + c.getString(21) + "', 0)");
128 c.moveToNext();
129 }
130 }
131 c.close();
132
133 // Log.w("Status:", "Copy to temp completed");
134
135 // Drop old table
136 db.execSQL("DROP TABLE IF EXISTS tblFavTimes");
137
138 // Recreate table
139 db.execSQL("CREATE TABLE tblFavTimes (_id int, favName text, filmName text, filmISO string, filmType int, devName text, devDilution text, devVolume int, devTempInC double, devTimeA int, devTimeB double, stopBathTime int, fixingTimeA int, fixingTimeB int, hypoClearTime int, rinsingTime int, photoFloTime int, agitationStart int, agitationAfter int, agitationRepeat int, notesTitle text null, notesBody text null, tempTimeConv int NOT NULL DEFAULT 0)");
140
141 // Copy data back to new table
142 c = db.rawQuery("SELECT * FROM tblFavTimesTEMP ORDER BY _id ASC", null);
143
144 // Get data from old table and copy to temp table
145 c.moveToFirst();
146 if (!c.isAfterLast()) {
147 while (!c.isAfterLast()) {
148 db.execSQL("INSERT INTO tblFavTimes ('_id', 'favName', 'filmName', 'filmISO', 'filmType', 'devName', 'devDilution', 'devVolume', 'devTempInC', 'devTimeA', 'devTimeB', 'stopBathTime', 'fixingTimeA', 'fixingTimeB', 'hypoClearTime', 'rinsingTime', 'photoFloTime', 'agitationStart', 'agitationAfter' , 'agitationRepeat', 'notesTitle', 'notesBody', 'tempTimeConv') VALUES("
149 + c.getString(0)
150 + ", '"
151 + c.getString(1)
152 + "', '"
153 + c.getString(2)
154 + "',"
155 + c.getString(3)
156 + ","
157 + c.getString(4)
158 + ", '"
159 + c.getString(5)
160 + "', '"
161 + c.getString(6)
162 + "', "
163 + c.getString(7)
164 + ","
165 + c.getString(8)
166 + ","
167 + c.getString(9)
168 + ","
169 + c.getString(10)
170 + ","
171 + c.getString(11)
172 + ","
173 + c.getString(12)
174 + ","
175 + c.getString(13)
176 + ","
177 + c.getString(14)
178 + ","
179 + c.getString(15)
180 + ","
181 + c.getString(16)
182 + ","
183 + c.getString(17)
184 + ","
185 + c.getString(18)
186 + ","
187 + c.getString(19)
188 + ",'"
189 + c.getString(20) + "', '" + c.getString(21) + "', 0)");
190 c.moveToNext();
191 }
192 }
193 c.close();
194
195 // Drop temp table
196 db.execSQL("DROP TABLE IF EXISTS tblFavTimesTEMP");
197
198 // Log.w("Status:", "Copy to back completed!");
199
200 }
201
202 }
203 }
204
205 // ---opens the database---
206 public favDBAdapter open() throws SQLException {
207 favDB = DBHelper.getWritableDatabase();
208 return this;
209 }
210
211 // ---closes the database---
212 public void close() {
213 DBHelper.close();
214 }
215
216 // ---Get Fav Name---
217 public boolean favsExist() {
218 Cursor c;
219 boolean response = false;
220
221 this.open();
222
223 c = favDB.rawQuery("SELECT favName FROM tblFavTimes", null);
224
225 if (c.moveToFirst() == false) {
226 response = false;
227 } else {
228 response = true;
229 }
230
231 this.close();
232 c.close();
233
234 return response;
235 }
236
237 // ---Add fav---
238 public void addFav(int favID, String favName, String filmName, String filmISO, int filmType, String devName, String devDilution, int devVolume, int devTempInC, int devTimeA, int devTimeB,
239 int stopBathTime, int fixingTimeA, int fixingTimeB, int hypoClearTime, int rinsingTime, int photoFloTime, int agitationStart, int agitationAfter, int agitationRepeat, String notesTitle,
240 String notesBody, int tempTimeConv) {
241 notesTitle = notesTitle.replace("'", "&APOS");
242 notesBody = notesBody.replace("'", "&APOS");
243
244 this.open();
245 favDB.execSQL("INSERT INTO tblFavTimes ('_id', 'favName', 'filmName', 'filmISO', 'filmType', 'devName', 'devDilution', 'devVolume', 'devTempInC', 'devTimeA', 'devTimeB', 'stopBathTime', 'fixingTimeA', 'fixingTimeB', 'hypoClearTime', 'rinsingTime', 'photoFloTime', 'agitationStart', 'agitationAfter' , 'agitationRepeat', 'notesTitle', 'notesBody', 'tempTimeConv') VALUES("
246 + favID
247 + ", '"
248 + favName.replace("'", "''")
249 + "', '"
250 + filmName
251 + "','"
252 + filmISO
253 + "',"
254 + filmType
255 + ", '"
256 + devName.replace("'", "''")
257 + "', '"
258 + devDilution
259 + "', "
260 + devVolume
261 + ","
262 + devTempInC
263 + ","
264 + devTimeA
265 + ","
266 + devTimeB
267 + ","
268 + stopBathTime
269 + ","
270 + fixingTimeA
271 + ","
272 + fixingTimeB
273 + ","
274 + hypoClearTime
275 + ","
276 + rinsingTime
277 + ","
278 + photoFloTime
279 + ","
280 + agitationStart + "," + agitationAfter + "," + agitationRepeat + ",'" + notesTitle + "', '" + notesBody + "', " + tempTimeConv + ")");
281 this.close();
282 }
283
284 // ---Delete fav---
285 public void deleteFav(int favID) {
286 this.open();
287 favDB.execSQL("DELETE FROM tblFavTimes WHERE _id = " + favID);
288 this.close();
289 }
290
291 public void deleteAllFav() {
292 this.open();
293 favDB.execSQL("DELETE FROM tblFavTimes");
294 this.close();
295 }
296
297 // ---retrieves All My Fav Times ---
298 public Cursor getAllFavs() {
299 return favDB.rawQuery("SELECT * FROM tblFavTimes ORDER BY _id ASC", null);
300 }
301
302 // ---Set fav dev volume---
303 public void setDevVolume(int favID, int input) {
304 this.open();
305 favDB.execSQL("UPDATE tblFavTimes SET devVolume = " + input + " WHERE _id = " + favID);
306 this.close();
307 }
308
309 // ---Set fav name ---
310 public void setFavName(int favID, String input) {
311 this.open();
312 favDB.execSQL("UPDATE tblFavTimes SET favName = '" + input.replace("'", "''") + "' WHERE _id = " + favID);
313 this.close();
314 }
315
316 // ---Set film name ---
317 public void setFilmName(int favID, String input) {
318 this.open();
319 favDB.execSQL("UPDATE tblFavTimes SET filmName = '" + input.replace("'", "''") + "' WHERE _id = " + favID);
320 this.close();
321 }
322
323 // ---Set film ISO ---
324 public void setFilmISO(int favID, String input) {
325 this.open();
326 favDB.execSQL("UPDATE tblFavTimes SET filmISO = '" + input.replace("'", "''") + "' WHERE _id = " + favID);
327 this.close();
328 }
329
330 // ---Set film type ---
331 public void setFilmType(int favID, int input) {
332 this.open();
333 favDB.execSQL("UPDATE tblFavTimes SET filmType = " + input + " WHERE _id = " + favID);
334 this.close();
335 }
336
337 // ---Set Dev name ---
338 public void setDevName(int favID, String input) {
339 this.open();
340 favDB.execSQL("UPDATE tblFavTimes SET devName = '" + input.replace("'", "''") + "' WHERE _id = " + favID);
341 this.close();
342 }
343
344 // ---Set Dev dilution ---
345 public void setDevDilu(int favID, String input) {
346 this.open();
347 favDB.execSQL("UPDATE tblFavTimes SET devDilution = '" + input.replace("'", "''") + "' WHERE _id = " + favID);
348 this.close();
349 }
350
351 // ---Set Dev temp in C ---
352 public void setDevTempInC(int favID, Double input) {
353 this.open();
354 favDB.execSQL("UPDATE tblFavTimes SET devTempInC = " + input + " WHERE _id = " + favID);
355 this.close();
356 }
357
358 // ---Set Dev Time A ---
359 public void setDevTimeA(int favID, int input) {
360 this.open();
361 favDB.execSQL("UPDATE tblFavTimes SET devTimeA = " + input + " WHERE _id = " + favID);
362 this.close();
363 }
364
365 // ---Set Dev Time B ---
366 public void setDevTimeB(int favID, int input) {
367 this.open();
368 favDB.execSQL("UPDATE tblFavTimes SET devTimeB = " + input + " WHERE _id = " + favID);
369 this.close();
370 }
371
372 // ---Set Stop Bath ---
373 public void setStopBath(int favID, int input) {
374 this.open();
375 favDB.execSQL("UPDATE tblFavTimes SET stopBathTime = " + input + " WHERE _id = " + favID);
376 this.close();
377 }
378
379 // ---Set Fixing A ---
380 public void setFixingA(int favID, int input) {
381 this.open();
382 favDB.execSQL("UPDATE tblFavTimes SET fixingTimeA = " + input + " WHERE _id = " + favID);
383 this.close();
384 }
385
386 // ---Set Fixing B ---
387 public void setFixingB(int favID, int input) {
388 this.open();
389 favDB.execSQL("UPDATE tblFavTimes SET fixingTimeB = " + input + " WHERE _id = " + favID);
390 this.close();
391 }
392
393 // ---Set HypoClear ---
394 public void setHypoClear(int favID, int input) {
395 this.open();
396 favDB.execSQL("UPDATE tblFavTimes SET hypoClearTime = " + input + " WHERE _id = " + favID);
397 this.close();
398 }
399
400 // ---Set Rinsing ---
401 public void setRinsing(int favID, int input) {
402 this.open();
403 favDB.execSQL("UPDATE tblFavTimes SET rinsingTime = " + input + " WHERE _id = " + favID);
404 this.close();
405 }
406
407 // ---Set PhotoFlow ---
408 public void setPhotoFlow(int favID, int input) {
409 this.open();
410 favDB.execSQL("UPDATE tblFavTimes SET photoFloTime = " + input + " WHERE _id = " + favID);
411 this.close();
412 }
413
414 // ---Set Agitation Start ---
415 public void setAgitationStart(int favID, int input) {
416 this.open();
417 favDB.execSQL("UPDATE tblFavTimes SET agitationStart = " + input + " WHERE _id = " + favID);
418 this.close();
419 }
420
421 // ---Set Agitation After ---
422 public void setAgitationAfter(int favID, int input) {
423 this.open();
424 favDB.execSQL("UPDATE tblFavTimes SET agitationAfter = " + input + " WHERE _id = " + favID);
425 this.close();
426 }
427
428 // ---Set Agitation Repeat ---
429 public void setAgitationRepeat(int favID, int input) {
430 this.open();
431 favDB.execSQL("UPDATE tblFavTimes SET agitationRepeat = " + input + " WHERE _id = " + favID);
432 this.close();
433 }
434
435 // ---Set Notes Title ---
436 public void setNotesTitle(int favID, String input) {
437 this.open();
438 input = input.replace("'", "&APOS");
439 favDB.execSQL("UPDATE tblFavTimes SET notesTitle = '" + input.replace("'", "''") + "' WHERE _id = " + favID);
440 this.close();
441 }
442
443 // ---Set Notes Body ---
444 public void setNotesBody(int favID, String input) {
445 this.open();
446 input = input.replace("'", "&APOS");
447 favDB.execSQL("UPDATE tblFavTimes SET notesBody = '" + input.replace("'", "''") + "' WHERE _id = " + favID);
448 this.close();
449 }
450
451 // ---Set fav tempTimeConv ---
452 public void setTempTimeConf(int favID, int input) {
453 this.open();
454 favDB.execSQL("UPDATE tblFavTimes SET tempTimeConv = " + input + " WHERE _id = " + favID);
455 this.close();
456 }
457
458 // ---Get Next Available FavID ---
459 public int getNextFavID() {
460 Cursor c;
461 int response = 0;
462
463 this.open();
464
465 c = favDB.rawQuery("SELECT _id FROM tblFavTimes ORDER BY _id DESC", null);
466 c.moveToFirst();
467 if (!c.isAfterLast()) {
468 response = c.getInt(0);
469 }
470
471 // Increment to get next possible ID
472 response++;
473
474 this.close();
475 c.close();
476
477 return response;
478 }
479
480 // ---Get Fav Name---
481 public String getFavName(int favID) {
482 Cursor c;
483 String response = "";
484
485 this.open();
486
487 c = favDB.rawQuery("SELECT favName FROM tblFavTimes WHERE _id = " + favID, null);
488 c.moveToFirst();
489 if (!c.isAfterLast()) {
490 response = c.getString(0);
491 }
492
493 this.close();
494 c.close();
495 return response;
496 }
497
498 // ---Get Film Name---
499 public String getFilmName(int favID) {
500 Cursor c;
501 String response = "";
502
503 this.open();
504
505 c = favDB.rawQuery("SELECT filmName FROM tblFavTimes WHERE _id = " + favID, null);
506 c.moveToFirst();
507 if (!c.isAfterLast()) {
508 response = c.getString(0);
509 }
510
511 this.close();
512 c.close();
513 return response;
514 }
515
516 //get JSON for export
517 public JSONObject getJSON(String favID) {
518
519 Cursor c;
520 this.open();
521 JSONObject object = new JSONObject();
522
523 c = favDB.rawQuery("SELECT * FROM tblFavTimes WHERE _id = " + favID, null);
524 c.moveToFirst();
525 if (!c.isAfterLast()) {
526
527 String filmType = "";
528
529 switch (c.getInt(c.getColumnIndex("filmType"))) {
530 case 0:
531 filmType = "35mm";
532 break;
533 case 1:
534 filmType = "120";
535 break;
536 case 2:
537 filmType = "Sheet";
538 break;
539 }
540
541 try {
542
543 int isDevTimesAdjusted = c.getInt(c.getColumnIndex("tempTimeConv"));
544
545 object.put("name", c.getString(c.getColumnIndex("favName")));
546 object.put("filmName", c.getString(c.getColumnIndex("filmName")));
547 object.put("filmISO", c.getString(c.getColumnIndex("filmISO")));
548 object.put("filmType", filmType);
549 object.put("developerName", c.getString(c.getColumnIndex("devName")));
550 object.put("developerDilution", c.getString(c.getColumnIndex("devDilution")));
551 object.put("developerVolume", c.getInt(c.getColumnIndex("devVolume")));
552
553 object.put("developmentTemperature", c.getInt(c.getColumnIndex("devTempInC")));
554 object.put("developmentTimeA", c.getInt(c.getColumnIndex("devTimeA")));
555 object.put("developmentTimeB", c.getInt(c.getColumnIndex("devTimeB")));
556 object.put("developmentTemperatureAdjusted", c.getInt(c.getColumnIndex("devTempInC")));
557 object.put("developmentTimeAAdjusted", c.getInt(c.getColumnIndex("devTimeA")));
558 object.put("developmentTimeBAdjusted", c.getInt(c.getColumnIndex("devTimeB")));
559
560 object.put("stopBathTime", c.getInt(c.getColumnIndex("stopBathTime")));
561 object.put("fixingTimeA", c.getInt(c.getColumnIndex("fixingTimeA")));
562 object.put("fixingTimeB", c.getInt(c.getColumnIndex("fixingTimeB")));
563 object.put("hypoClearTime", c.getInt(c.getColumnIndex("hypoClearTime")));
564 object.put("rinsingTime", c.getInt(c.getColumnIndex("rinsingTime")));
565 object.put("photofloTime", c.getInt(c.getColumnIndex("photoFloTime")));
566 object.put("inversionsInitial", c.getInt(c.getColumnIndex("agitationStart")));
567 object.put("inversionsNext", c.getInt(c.getColumnIndex("agitationAfter")));
568 object.put("inversionsRepeat", c.getInt(c.getColumnIndex("agitationRepeat")));
569 object.put("notes", c.getString(c.getColumnIndex("notesTitle")));
570 object.put("notesLong", c.getString(c.getColumnIndex("notesBody")));
571 object.put("tempTimeConv", isDevTimesAdjusted);
572 object.put("developmentTimesAdjusted", isDevTimesAdjusted);
573
574 } catch (Exception e) {
575 e.printStackTrace();
576 }
577 }
578
579 this.close();
580 c.close();
581 return object;
582 }
583
584 // ---Get Film ISO---
585 public String getFilmISO(int favID) {
586 Cursor c;
587 String response = "";
588
589 this.open();
590
591 c = favDB.rawQuery("SELECT filmISO FROM tblFavTimes WHERE _id = " + favID, null);
592 c.moveToFirst();
593 if (!c.isAfterLast()) {
594 response = c.getString(0);
595 }
596
597 this.close();
598 c.close();
599
600 return response;
601 }
602
603 // ---Get Film Type---
604 public int getFilmType(int favID) {
605 Cursor c;
606 int response = 0;
607
608 this.open();
609
610 c = favDB.rawQuery("SELECT filmType FROM tblFavTimes WHERE _id = " + favID, null);
611 c.moveToFirst();
612 if (!c.isAfterLast()) {
613 response = c.getInt(0);
614 }
615
616 this.close();
617 c.close();
618
619 return response;
620 }
621
622 // ---Get Dev Name---
623 public String getDevName(int favID) {
624 Cursor c;
625 String response = "";
626
627 this.open();
628
629 c = favDB.rawQuery("SELECT devName FROM tblFavTimes WHERE _id = " + favID, null);
630 c.moveToFirst();
631 if (!c.isAfterLast()) {
632 response = c.getString(0);
633 }
634
635 this.close();
636 c.close();
637
638 return response;
639 }
640
641 // ---Get Dev Dilu---
642 public String getDevDilu(int favID) {
643 Cursor c;
644 String response = "";
645
646 this.open();
647
648 c = favDB.rawQuery("SELECT devDilution FROM tblFavTimes WHERE _id = " + favID, null);
649 c.moveToFirst();
650 if (!c.isAfterLast()) {
651 response = c.getString(0);
652 }
653
654 this.close();
655 c.close();
656
657 return response;
658 }
659
660 // ---Get Dev Volume---
661 public int getDevVolume(int favID) {
662 Cursor c;
663 int response = 0;
664
665 this.open();
666
667 c = favDB.rawQuery("SELECT devVolume FROM tblFavTimes WHERE _id = " + favID, null);
668 c.moveToFirst();
669 if (!c.isAfterLast()) {
670 response = c.getInt(0);
671 }
672
673 this.close();
674 c.close();
675
676 return response;
677 }
678
679 // ---Get Dev Temp (in C)---
680 public double getDevTempInC(int favID) {
681 Cursor c;
682 double response = 0;
683
684 this.open();
685
686 c = favDB.rawQuery("SELECT devTempInC FROM tblFavTimes WHERE _id = " + favID, null);
687 c.moveToFirst();
688 if (!c.isAfterLast()) {
689 response = c.getDouble(0);
690 }
691
692 this.close();
693 c.close();
694
695 return response;
696 }
697
698 // ---Get Dev Time A---
699 public int getDevTimeA(int favID) {
700 Cursor c;
701 int response = 0;
702
703 this.open();
704
705 c = favDB.rawQuery("SELECT devTimeA FROM tblFavTimes WHERE _id = " + favID, null);
706 c.moveToFirst();
707 if (!c.isAfterLast()) {
708 response = c.getInt(0);
709 }
710
711 this.close();
712 c.close();
713
714 return response;
715 }
716
717 // ---Get Dev Time B---
718 public int getDevTimeB(int favID) {
719 Cursor c;
720 int response = 0;
721
722 this.open();
723
724 c = favDB.rawQuery("SELECT devTimeB FROM tblFavTimes WHERE _id = " + favID, null);
725 c.moveToFirst();
726 if (!c.isAfterLast()) {
727 response = c.getInt(0);
728 }
729
730 this.close();
731 c.close();
732
733 return response;
734 }
735
736 // ---Get StopBath Time ---
737 public int getStopBathTime(int favID) {
738 Cursor c;
739 int response = 0;
740
741 this.open();
742
743 c = favDB.rawQuery("SELECT stopBathTime FROM tblFavTimes WHERE _id = " + favID, null);
744 c.moveToFirst();
745 if (!c.isAfterLast()) {
746 response = c.getInt(0);
747 }
748
749 this.close();
750 c.close();
751
752 return response;
753 }
754
755 // ---Get Fixing Time A---
756 public int getFixingTimeA(int favID) {
757 Cursor c;
758 int response = 0;
759
760 this.open();
761
762 c = favDB.rawQuery("SELECT fixingTimeA FROM tblFavTimes WHERE _id = " + favID, null);
763 c.moveToFirst();
764 if (!c.isAfterLast()) {
765 response = c.getInt(0);
766 }
767
768 this.close();
769 c.close();
770
771 return response;
772 }
773
774 // ---Get Fixing Time B---
775 public int getFixingTimeB(int favID) {
776 Cursor c;
777 int response = 0;
778
779 this.open();
780
781 c = favDB.rawQuery("SELECT fixingTimeB FROM tblFavTimes WHERE _id = " + favID, null);
782 c.moveToFirst();
783 if (!c.isAfterLast()) {
784 response = c.getInt(0);
785 }
786
787 this.close();
788 c.close();
789
790 return response;
791 }
792
793 // ---Get Hypo Clear ---
794 public int getHypoClearTime(int favID) {
795 Cursor c;
796 int response = 0;
797
798 this.open();
799
800 c = favDB.rawQuery("SELECT hypoClearTime FROM tblFavTimes WHERE _id = " + favID, null);
801 c.moveToFirst();
802 if (!c.isAfterLast()) {
803 response = c.getInt(0);
804 }
805
806 this.close();
807 c.close();
808
809 return response;
810 }
811
812 // ---Get Rinsing Clear ---
813 public int getRinsingTime(int favID) {
814 Cursor c;
815 int response = 0;
816
817 this.open();
818
819 c = favDB.rawQuery("SELECT rinsingTime FROM tblFavTimes WHERE _id = " + favID, null);
820 c.moveToFirst();
821 if (!c.isAfterLast()) {
822 response = c.getInt(0);
823 }
824
825 this.close();
826 c.close();
827
828 return response;
829 }
830
831 // ---Get Hypo Clear ---
832 public int getPhotoFloTime(int favID) {
833 Cursor c;
834 int response = 0;
835
836 this.open();
837
838 c = favDB.rawQuery("SELECT photoFloTime FROM tblFavTimes WHERE _id = " + favID, null);
839 c.moveToFirst();
840 if (!c.isAfterLast()) {
841 response = c.getInt(0);
842 }
843
844 this.close();
845 c.close();
846
847 return response;
848 }
849
850 // ---Get Agitation Start ---
851 public int getAgitationStart(int favID) {
852 Cursor c;
853 int response = 0;
854
855 this.open();
856
857 c = favDB.rawQuery("SELECT agitationStart FROM tblFavTimes WHERE _id = " + favID, null);
858 c.moveToFirst();
859 if (!c.isAfterLast()) {
860 response = c.getInt(0);
861 }
862
863 this.close();
864 c.close();
865
866 return response;
867 }
868
869 // ---Get Agitation After ---
870 public int getAgitationAfter(int favID) {
871 Cursor c;
872 int response = 0;
873
874 this.open();
875
876 c = favDB.rawQuery("SELECT agitationAfter FROM tblFavTimes WHERE _id = " + favID, null);
877 c.moveToFirst();
878 if (!c.isAfterLast()) {
879 response = c.getInt(0);
880 }
881
882 this.close();
883 c.close();
884
885 return response;
886 }
887
888 // ---Get Agitation Repeat ---
889 public int getAgitationRepeat(int favID) {
890 Cursor c;
891 int response = 0;
892
893 this.open();
894
895 c = favDB.rawQuery("SELECT agitationRepeat FROM tblFavTimes WHERE _id = " + favID, null);
896 c.moveToFirst();
897 if (!c.isAfterLast()) {
898 response = c.getInt(0);
899 }
900
901 this.close();
902 c.close();
903
904 return response;
905 }
906
907 // ---Get Notes Title---
908 public String getNotesTitle(int favID) {
909 Cursor c;
910 String response = "";
911
912 this.open();
913
914 c = favDB.rawQuery("SELECT notesTitle FROM tblFavTimes WHERE _id = " + favID, null);
915 c.moveToFirst();
916 if (!c.isAfterLast()) {
917 response = c.getString(0);
918 response = response.replace("&APOS", "'");
919 }
920
921 this.close();
922 c.close();
923
924 return response;
925 }
926
927 // ---Get Notes Body---
928 public String getNotesBody(int favID) {
929 Cursor c;
930 String response = "";
931
932 this.open();
933
934 c = favDB.rawQuery("SELECT notesBody FROM tblFavTimes WHERE _id = " + favID, null);
935 c.moveToFirst();
936 if (!c.isAfterLast()) {
937 response = c.getString(0);
938 response = response.replace("&APOS", "'");
939 }
940
941 this.close();
942 c.close();
943
944 return response;
945 }
946
947 // ---Get TempTimeConv Value---
948 public int getTempTimeConv(int favID) {
949 Cursor c;
950 int response = 0;
951
952 this.open();
953
954 c = favDB.rawQuery("SELECT tempTimeConv FROM tblFavTimes WHERE _id = " + favID, null);
955 c.moveToFirst();
956 if (!c.isAfterLast()) {
957 response = c.getInt(0);
958 }
959
960 this.close();
961 c.close();
962
963 return response;
964 }
965}