· 8 years ago · Dec 20, 2017, 11:32 AM
1package gymhelp.feup.org.pushupfit;
2
3import android.content.ContentValues;
4import android.content.Context;
5import android.content.Intent;
6import android.database.Cursor;
7import android.database.sqlite.SQLiteDatabase;
8import android.database.sqlite.SQLiteOpenHelper;
9import android.util.Log;
10
11import java.util.ArrayList;
12import java.util.List;
13
14/**
15 * Created by Paulo Maia on 18/11/2017.
16 */
17
18public class DatabaseHandler extends SQLiteOpenHelper {
19
20 // All Static variables
21 // Database Version
22 private static final int DATABASE_VERSION = 1;
23 public Boolean isLogin;
24
25 // Database Name
26 private static final String DATABASE_NAME = "userManager";
27
28 // table names
29 private static final String TABLE_CONTACTS = "users";
30 private static final String TABLE_ACTIVITY="activities";
31 private static final String TABLE_MONITORING="monitoring";
32 private static final String TABLE_CALIBRATION="calibration";
33 private static final String TABLE_YMCA="ymca";
34 private static final String TABLE_EXPERIENCE="experience";
35
36
37
38 // Contacts Table Columns names
39 private static final String USER_ID = "user_id";
40 private static final String NAME = "name";
41 private static final String PW = "password";
42 private static final String AGE = "age";
43 private static final String GENDER = "gender";
44 private static final String UP_NO = "up_number";
45 private static final String XP = "user_exp";
46 private static final String DAY1="day1";
47
48 //Activities Table Column names
49 private static final String ACT_ID="activity_id";
50 private static final String ACT_NAME="activity_name";
51 private static final String ACT_DATE="activity_date";
52
53 //Monitoring Table Column names
54 private static final String MONI_ID="monitoring_id";
55 private static final String MEAN_RC="mean_rc";
56 private static final String OPTIMAL_TRAINING_TIME="opti_train_time";
57
58 //Calibration Table Column names
59 private static final String CALI_ID="calibration_id";
60 private static final String BASAL_RC="basal_rc";
61 private static final String CALI_DATE="calibration_date";
62
63 //YMCA Table Column names
64 private static final String YMCA_ID="ymca_id";
65 private static final String YMCA_RC="ymca_rc";
66 private static final String YMCA_DATE="ymca_date";
67
68 //Experience Table Column names
69 private static final String EXPERIENCE_ID="exp_id";
70 private static final String EXPERIENCE="exp";
71 private static final String EXPERIENCE_DATE="exp_date";
72
73
74
75
76 private static final String CREATE_CONTACTS_TABLE="CREATE TABLE " + TABLE_CONTACTS + "("
77 + USER_ID + " INTEGER PRIMARY KEY," + NAME + " TEXT,"
78 + UP_NO + " TEXT," + PW + " TEXT," + XP + " INTEGER," + GENDER +" TEXT," + AGE +" AGE,"+ DAY1 + " TEXT"+ ")";
79
80 private static final String CREATE_ACTIVITIES_TABLE= "CREATE TABLE " + TABLE_ACTIVITY + "("
81 + ACT_ID + " INTEGER PRIMARY KEY," + ACT_NAME + " TEXT," + ACT_DATE + " TEXT," + USER_ID + " INTEGER, FOREIGN KEY ("+USER_ID+") REFERENCES "+TABLE_CONTACTS+"("+TABLE_CONTACTS+") ON DELETE CASCADE" +")";
82
83 private static final String CREATE_MONITORING_TABLE= "CREATE TABLE " + TABLE_MONITORING + "("
84 + MONI_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + MEAN_RC + " TEXT," + OPTIMAL_TRAINING_TIME + " TEXT," + ACT_ID + " INTEGER," + USER_ID + " INTEGER, " + "FOREIGN KEY ("+ACT_ID+") REFERENCES "+TABLE_ACTIVITY+"("+TABLE_ACTIVITY+") ON DELETE CASCADE, FOREIGN KEY ("+USER_ID+") REFERENCES "+TABLE_CONTACTS+"("+TABLE_CONTACTS+") ON DELETE CASCADE" +")";
85
86 private static final String CREATE_CALIBRATION_TABLE= "CREATE TABLE " + TABLE_CALIBRATION + "("
87 + CALI_ID + " INTEGER PRIMARY KEY," + BASAL_RC + " TEXT," + CALI_DATE + " TEXT," + USER_ID + " INTEGER, FOREIGN KEY ("+USER_ID+") REFERENCES "+TABLE_CONTACTS+"("+TABLE_CONTACTS+") ON DELETE CASCADE" +")";
88
89 private static final String CREATE_YMCA_TABLE= "CREATE TABLE " + TABLE_YMCA + "("
90 + YMCA_ID + " INTEGER PRIMARY KEY," + YMCA_RC + " TEXT," + YMCA_DATE + " TEXT," + USER_ID + " INTEGER, FOREIGN KEY ("+USER_ID+") REFERENCES "+TABLE_CONTACTS+"("+TABLE_CONTACTS+") ON DELETE CASCADE" +")";
91
92 private static final String CREATE_EXPERIENCE_TABLE= "CREATE TABLE " + TABLE_EXPERIENCE + "("
93 + EXPERIENCE_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + EXPERIENCE + " INTEGER," + EXPERIENCE_DATE + " TEXT," + USER_ID + " INTEGER, FOREIGN KEY ("+USER_ID+") REFERENCES "+TABLE_CONTACTS+"("+TABLE_CONTACTS+") ON DELETE CASCADE" +")";
94
95
96
97 Context _context;
98
99 public DatabaseHandler(Context context) {
100 super(context, DATABASE_NAME, null, DATABASE_VERSION);
101 this._context=context;
102 }
103
104 // Creating Tables
105 @Override
106 public void onCreate(SQLiteDatabase db) {
107 db.execSQL(CREATE_CONTACTS_TABLE);
108 db.execSQL(CREATE_ACTIVITIES_TABLE);
109 db.execSQL(CREATE_MONITORING_TABLE);
110 db.execSQL(CREATE_CALIBRATION_TABLE);
111 db.execSQL(CREATE_YMCA_TABLE);
112 db.execSQL(CREATE_EXPERIENCE_TABLE);
113
114 }
115
116 // Upgrading database
117 @Override
118 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
119 // Drop older table if existed
120 db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);
121 db.execSQL("DROP TABLE IF EXISTS " + TABLE_ACTIVITY);
122 db.execSQL("DROP TABLE IF EXISTS " + TABLE_MONITORING);
123 db.execSQL("DROP TABLE IF EXISTS " + TABLE_CALIBRATION);
124 db.execSQL("DROP TABLE IF EXISTS " + TABLE_YMCA);
125 db.execSQL("DROP TABLE IF EXISTS " + TABLE_EXPERIENCE);
126
127
128
129
130
131
132 // Create tables again
133 onCreate(db);
134 }
135
136 //YMCA functions
137
138 //adding EXPERIENCE
139 public void addExperience(Experience experience){
140 SQLiteDatabase db=this.getWritableDatabase();
141
142 ContentValues values = new ContentValues();
143 values.put(EXPERIENCE, experience.getEXP());
144 values.put(EXPERIENCE_DATE, experience.getEXP_date());
145 values.put(USER_ID, experience.getUser_id());
146
147 // Inserting Row
148 db.insert(TABLE_EXPERIENCE, null, values);
149 db.close(); // Closing database connection
150
151 };
152
153 public Experience getEXP(int user_id) {
154 SQLiteDatabase db = this.getReadableDatabase();
155
156 Cursor cursor = db.query(TABLE_EXPERIENCE, new String[] { EXPERIENCE_ID, EXPERIENCE, EXPERIENCE_DATE, USER_ID
157 }, USER_ID + "=?",
158 new String[] { String.valueOf(user_id) }, null, null, null, null);
159 if (cursor != null)
160 cursor.moveToFirst();
161
162 Experience experience = new Experience(cursor.getInt(0), Integer.parseInt(cursor.getString(1)), cursor.getString(2),
163 Integer.parseInt(cursor.getString(3)));
164
165 return experience;
166 }
167
168 public List<Experience> getAllEXPsuserid(int user_id) {
169 List<Experience> EXPList = new ArrayList<Experience>();
170 SQLiteDatabase db = this.getReadableDatabase();
171
172
173 Cursor cursor = db.query(TABLE_EXPERIENCE, new String[] { EXPERIENCE_ID, EXPERIENCE, EXPERIENCE_DATE, USER_ID
174 }, USER_ID + "=?",
175 new String[] { String.valueOf(user_id) }, null, null, null, null);
176
177 // looping through all rows and adding to list
178 if (cursor.moveToFirst()) {
179 do {
180 Experience experience = new Experience(cursor.getInt(0), Integer.parseInt(cursor.getString(1)), cursor.getString(2),
181 Integer.parseInt(cursor.getString(3)));
182
183
184 // Adding calibration to list
185 EXPList.add(experience);
186 } while (cursor.moveToNext());
187 }
188
189 return EXPList;
190 }
191
192 public List<String> getTotalEXPsuserid(int user_id, String exp_date) {
193 List<String> EXPList = new ArrayList<String>();
194 SQLiteDatabase db = this.getReadableDatabase();
195
196 String table = TABLE_EXPERIENCE;
197 String[] columns = new String[] { "sum(exp)" };
198 String selection = USER_ID + "=? and " +EXPERIENCE_DATE + "=?";
199 String[] arguments = new String[] { String.valueOf(user_id), exp_date };
200 String groupBy = "user_id, exp_date";
201 String having = null;
202 String orderBy = null;
203 Cursor cursor = db.query(table, columns, selection, arguments, groupBy, having, orderBy);
204
205
206 // looping through all rows and adding to list
207 if (cursor.moveToFirst()) {
208 do {
209 EXPList.add(cursor.getString(0));
210
211
212 } while (cursor.moveToNext());
213 }
214
215 cursor.close();
216
217 return EXPList;
218 }
219
220
221 //YMCA functions
222
223 //adding YMCA
224 public void addYMCA(YMCA ymca){
225 SQLiteDatabase db=this.getWritableDatabase();
226
227 ContentValues values = new ContentValues();
228 values.put(YMCA_ID,ymca.getYMCA_id());
229 values.put(YMCA_RC, ymca.getYMCA_rc());
230 values.put(YMCA_DATE, ymca.getYMCA_date());
231 values.put(USER_ID, ymca.getUser_id());
232
233 // Inserting Row
234 db.insert(TABLE_YMCA, null, values);
235 db.close(); // Closing database connection
236
237 };
238
239 public YMCA getfirstYMCA(int user_id) {
240 SQLiteDatabase db = this.getReadableDatabase();
241
242 Cursor cursor = db.query(TABLE_YMCA, new String[] { YMCA_ID, YMCA_RC, YMCA_DATE, USER_ID
243 }, USER_ID + "=?",
244 new String[] { String.valueOf(user_id) }, null, null, null, null);
245 if (cursor != null)
246 cursor.moveToFirst();
247
248 YMCA ymca = new YMCA(Integer.parseInt(cursor.getString(0)), cursor.getString(1), cursor.getString(2),
249 Integer.parseInt(cursor.getString(3)));
250
251 return ymca;
252 }
253
254 public YMCA getlastYMCA(int user_id) {
255 SQLiteDatabase db = this.getReadableDatabase();
256
257 Cursor cursor = db.query(TABLE_YMCA, new String[] { YMCA_ID, YMCA_RC, YMCA_DATE, USER_ID
258 }, USER_ID + "=?",
259 new String[] { String.valueOf(user_id) }, null, null, null, null);
260 if (cursor != null)
261 cursor.moveToLast();
262
263 YMCA ymca = new YMCA(Integer.parseInt(cursor.getString(0)), cursor.getString(1), cursor.getString(2),
264 Integer.parseInt(cursor.getString(3)));
265
266 return ymca;
267 }
268
269 public List<YMCA> getAllYMCAsuserid(int user_id) {
270 List<YMCA> YMCAList = new ArrayList<YMCA>();
271 SQLiteDatabase db = this.getReadableDatabase();
272
273
274 Cursor cursor = db.query(TABLE_YMCA, new String[] { YMCA_ID, YMCA_RC, YMCA_DATE, USER_ID
275 }, USER_ID + "=?",
276 new String[] { String.valueOf(user_id) }, null, null, null, null);
277
278 // looping through all rows and adding to list
279 if (cursor.moveToFirst()) {
280 do {
281 YMCA ymca = new YMCA(Integer.parseInt(cursor.getString(0)),cursor.getString(1), cursor.getString(2),
282 Integer.parseInt(cursor.getString(3)));
283
284
285 // Adding calibration to list
286 YMCAList.add(ymca);
287 } while (cursor.moveToNext());
288 }
289
290 return YMCAList;
291 }
292
293//calibration functions
294
295 //adding calibration
296 public void addCalibration(Calibration calibration){
297 SQLiteDatabase db=this.getWritableDatabase();
298
299 ContentValues values = new ContentValues();
300 values.put(CALI_ID,calibration.getCali_id());
301 values.put(BASAL_RC, calibration.getBasal_rc());
302 values.put(CALI_DATE, calibration.getCali_date());
303 values.put(USER_ID, calibration.getUser_id());
304
305 // Inserting Row
306 db.insert(TABLE_CALIBRATION, null, values);
307 db.close(); // Closing database connection
308
309 };
310
311 public Calibration getCalibration(int user_id) {
312 SQLiteDatabase db = this.getReadableDatabase();
313
314 Cursor cursor = db.query(TABLE_CALIBRATION, new String[] { CALI_ID, BASAL_RC, CALI_DATE, USER_ID
315 }, USER_ID + "=?",
316 new String[] { String.valueOf(user_id) }, null, null, null, null);
317 if (cursor != null)
318 cursor.moveToFirst();
319
320 Calibration calibration = new Calibration(Integer.parseInt(cursor.getString(0)), Double.parseDouble(cursor.getString(1)), cursor.getString(2),
321 Integer.parseInt(cursor.getString(3)));
322
323 return calibration;
324 }
325
326 public List<Calibration> getAllCalibrations_userid(int user_id) {
327 List<Calibration> caliList = new ArrayList<Calibration>();
328 SQLiteDatabase db = this.getReadableDatabase();
329
330
331 Cursor cursor = db.query(TABLE_CALIBRATION, new String[] { CALI_ID, BASAL_RC, CALI_DATE, USER_ID
332 }, USER_ID + "=?",
333 new String[] { String.valueOf(user_id) }, null, null, null, null);
334
335 // looping through all rows and adding to list
336 if (cursor.moveToFirst()) {
337 do {
338 Calibration calibration = new Calibration(Integer.parseInt(cursor.getString(0)), Double.parseDouble(cursor.getString(1)), cursor.getString(2),
339 Integer.parseInt(cursor.getString(3)));
340
341
342 // Adding calibration to list
343 caliList.add(calibration);
344 } while (cursor.moveToNext());
345 }
346
347 return caliList;
348 }
349
350// monitoring functions
351
352 //adding monitoring
353 public void addMonitoring(TrainingStatistics monitoring){
354 SQLiteDatabase db=this.getWritableDatabase();
355
356 ContentValues values = new ContentValues();
357 // values.put(MONI_ID,monitoring.getMoni_id());
358 values.put(MEAN_RC, monitoring.getMean_rc());
359 values.put(OPTIMAL_TRAINING_TIME, monitoring.getOptimal_training_time());
360 values.put(ACT_ID, monitoring.getActivity_id());
361 values.put(USER_ID, monitoring.getUser_id());
362
363 // Inserting Row
364 db.insert(TABLE_MONITORING, null, values);
365 db.close(); // Closing database connection
366
367 };
368
369 public TrainingStatistics getTrainingStatistics(int user_id) {
370 SQLiteDatabase db = this.getReadableDatabase();
371
372 Cursor cursor = db.query(TABLE_MONITORING, new String[] { MONI_ID, MEAN_RC, OPTIMAL_TRAINING_TIME, ACT_ID, USER_ID
373 }, USER_ID + "=?",
374 new String[] { String.valueOf(user_id) }, null, null, null, null);
375 if (cursor != null)
376 cursor.moveToFirst();
377
378 TrainingStatistics statistics = new TrainingStatistics(Integer.parseInt(cursor.getString(0)), Double.parseDouble(cursor.getString(1)), Double.parseDouble(cursor.getString(2)),
379 Integer.parseInt(cursor.getString(3)), Integer.parseInt(cursor.getString(4)));
380
381 return statistics;
382 }
383
384 public List<TrainingStatistics> getAllStatistics_userid(int user_id) {
385 List<TrainingStatistics> statList = new ArrayList<TrainingStatistics>();
386 SQLiteDatabase db = this.getReadableDatabase();
387
388
389 Cursor cursor = db.query(TABLE_MONITORING, new String[] { MONI_ID, MEAN_RC, OPTIMAL_TRAINING_TIME, ACT_ID,USER_ID
390 }, USER_ID + "=?",
391 new String[] { String.valueOf(user_id) }, null, null, null, null);
392
393 // looping through all rows and adding to list
394 if (cursor.moveToFirst()) {
395 do {
396 TrainingStatistics trainingStatistics = new TrainingStatistics(Integer.parseInt(cursor.getString(0)), Double.parseDouble(cursor.getString(1)), Double.parseDouble(cursor.getString(2)),
397 Integer.parseInt(cursor.getString(3)), Integer.parseInt(cursor.getString(4)));
398
399
400 // Adding statistics to list
401 statList.add(trainingStatistics);
402 } while (cursor.moveToNext());
403 }
404
405 return statList;
406 }
407
408
409
410
411
412
413// activity functions
414
415 //adding activity
416 public void addActivity(Phys_Activity activity){
417 SQLiteDatabase db=this.getWritableDatabase();
418
419 ContentValues values = new ContentValues();
420 values.put(ACT_NAME,activity.getName());
421 values.put(USER_ID, activity.getUser_id());
422 values.put(ACT_DATE, activity.getDate());
423
424 // Inserting Row
425 db.insert(TABLE_ACTIVITY, null, values);
426 db.close(); // Closing database connection
427
428 };
429
430
431 public Phys_Activity getActivity(int user_id) {
432 SQLiteDatabase db = this.getReadableDatabase();
433
434 Cursor cursor = db.query(TABLE_ACTIVITY, new String[] { ACT_ID, ACT_NAME, ACT_DATE, USER_ID
435 }, USER_ID + "=?",
436 new String[] { String.valueOf(user_id) }, null, null, null, null);
437 if (cursor != null)
438 cursor.moveToFirst();
439
440 Phys_Activity activity = new Phys_Activity(Integer.parseInt(cursor.getString(0)), cursor.getString(1), cursor.getString(2),
441 Integer.parseInt(cursor.getString(3)));
442
443 return activity;
444 }
445
446 public List<Phys_Activity> getAllActivities_userid(int user_id) {
447 List<Phys_Activity> actList = new ArrayList<Phys_Activity>();
448 SQLiteDatabase db = this.getReadableDatabase();
449
450
451 Cursor cursor = db.query(TABLE_ACTIVITY, new String[] { ACT_ID, ACT_NAME, ACT_DATE, USER_ID
452 }, USER_ID + "=?",
453 new String[] { String.valueOf(user_id) }, null, null, null, null);
454
455 // looping through all rows and adding to list
456 if (cursor.moveToFirst()) {
457 do {
458 Phys_Activity physicalAct = new Phys_Activity();
459 physicalAct.setAct_id(Integer.parseInt(cursor.getString(0)));
460 physicalAct.setName(cursor.getString(1));
461 physicalAct.setDate(cursor.getString(2));
462 physicalAct.setUser_id(Integer.parseInt(cursor.getString(3)));
463
464 // Adding activity to list
465 actList.add(physicalAct);
466 } while (cursor.moveToNext());
467 }
468
469 return actList;
470 }
471
472
473
474
475
476
477
478
479
480
481
482
483// user functions
484
485
486
487 //adding user
488
489 public void addUser(User user) {
490 SQLiteDatabase db = this.getWritableDatabase();
491
492 ContentValues values = new ContentValues();
493 values.put(NAME, user.getName()); // Contact Name
494 values.put(UP_NO, user.getupNumber()); // Contact Phone Number
495 values.put(PW, user.getPassword());
496 values.put(XP, user.getExperience());
497 values.put(GENDER, user.getGender());
498 values.put(AGE, user.getAge());
499 values.put(DAY1, user.getDay1());
500
501 // Inserting Row
502 db.insert(TABLE_CONTACTS, null, values);
503 db.close(); // Closing database connection
504 }
505
506
507
508 // Updating single user
509 public int updateUser(User user) {
510 SQLiteDatabase db = this.getWritableDatabase();
511
512 ContentValues values = new ContentValues();
513 values.put(NAME, user.getName());
514 values.put(PW, user.getPassword());
515 values.put(UP_NO, user.getupNumber());
516 values.put(XP, user.getExperience());
517 values.put(GENDER, user.getGender());
518 values.put(AGE, user.getAge());
519 values.put(DAY1, user.getDay1());
520
521
522 // updating row
523 return db.update(TABLE_CONTACTS, values, USER_ID + " = ?",
524 new String[] { String.valueOf(user.getId()) });
525 }
526
527 // Getting single contact
528 public User getUser(int id) {
529 SQLiteDatabase db = this.getReadableDatabase();
530
531 Cursor cursor = db.query(TABLE_CONTACTS, new String[] { USER_ID,
532 NAME, UP_NO, PW, XP, GENDER, AGE, DAY1 }, USER_ID + "=?",
533 new String[] { String.valueOf(id) }, null, null, null, null);
534 if (cursor != null)
535 cursor.moveToFirst();
536
537 User user = new User(Integer.parseInt(cursor.getString(0)),
538 cursor.getString(1), cursor.getString(2), cursor.getString(3),Integer.parseInt(cursor.getString(4)), cursor.getString(5),Integer.parseInt(cursor.getString(6)), cursor.getString(7));
539 // return user
540 return user;
541 }
542
543 // Getting All Contacts
544 public List<User> getAllUsers() {
545 List<User> userList = new ArrayList<User>();
546 // Select All Query
547 String selectQuery = "SELECT * FROM " + TABLE_CONTACTS;
548
549 SQLiteDatabase db = this.getWritableDatabase();
550 Cursor cursor = db.rawQuery(selectQuery, null);
551
552 // looping through all rows and adding to list
553 if (cursor.moveToFirst()) {
554 do {
555 User user = new User();
556 user.setId(Integer.parseInt(cursor.getString(0)));
557 user.setName(cursor.getString(1));
558 user.setUpNumber(cursor.getString(2));
559 user.setPassword(cursor.getString(3));
560 user.setExperience(Integer.parseInt(cursor.getString(4)));
561 user.setGender(cursor.getString(5));
562 user.setAge(Integer.parseInt(cursor.getString(6)));
563
564 // Adding user to list
565 userList.add(user);
566 } while (cursor.moveToNext());
567 }
568
569 // return user list
570 return userList;
571 }
572
573 // Getting users Count
574 public int getUsersCount() {
575 String countQuery = "SELECT * FROM " + TABLE_CONTACTS;
576 SQLiteDatabase db = this.getReadableDatabase();
577 Cursor cursor = db.rawQuery(countQuery, null);
578 cursor.close();
579
580 // return count
581 return cursor.getCount();
582 }
583
584
585 // Deleting single contact
586 public void deleteContact(User user) {
587 SQLiteDatabase db = this.getWritableDatabase();
588 db.delete(TABLE_CONTACTS, USER_ID + " = ?",
589 new String[] { String.valueOf(user.getId()) });
590 db.close();
591 }
592
593 // public User findLoggedUserInfo()
594 // {
595
596 // }
597
598 public void createLoginSession(){
599 // Storing login value as TRUE
600 isLogin = true;
601
602 }
603
604 public void checkLogin() {
605 // Check login status
606 if (isLogin!=null) {
607
608 // If the user is not logged in, redirect him to Login Activity
609 Intent i = new Intent(_context, LoginActivity.class);
610 // Closing all the Activities
611 i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
612
613 // Add new Flag to start new Activity
614 i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
615
616 // Staring Login Activity
617 _context.startActivity(i);
618 }
619 }
620
621 public void logoutUser(){
622 // Clearing all data from Shared Preferences
623 // editor.clear();
624 // editor.commit();
625
626 isLogin=false;
627
628 // After logout redirect user to Login Activity
629 Intent i = new Intent(_context, LoginActivity.class);
630 // Closing all the Activities
631 i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
632
633 // Add new Flag to start new Activity
634 i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
635
636 // Staring Login Activity
637 _context.startActivity(i);
638 }
639
640
641}