Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.92 KB | None | 0 0
  1. package sk.tuke.smart.bakalar;
  2.  
  3. import android.content.ContentValues;
  4. import android.content.Context;
  5. import android.database.Cursor;
  6. import android.database.sqlite.SQLiteDatabase;
  7. import android.database.sqlite.SQLiteOpenHelper;
  8. import android.icu.text.LocaleDisplayNames;
  9. import android.util.Log;
  10.  
  11. import java.security.Key;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14.  
  15. import sk.tuke.smart.bakalar.constants.GameTitles;
  16.  
  17. public class DatabaseHelper extends SQLiteOpenHelper
  18. {
  19. // Logcat tag
  20. private static final String TAG = "DatabaseHelper";
  21.  
  22. // Database Name
  23. private static final String DATABASE_NAME = "maindatabase.db";
  24.  
  25. // Database Version
  26. private static final int DATABASE_VERSION = 1;
  27.  
  28. // Table Names
  29. private static final String TABLE_USER = "users";
  30. private static final String TABLE_GAME = "games";
  31. private static final String TABLE_LEVEL = "levels";
  32.  
  33. // Common column names
  34. private static final String KEY_ID = "id";
  35.  
  36. // USERS Table - column names
  37. private static final String GAME_TAG = "game_tag";
  38. private static final String FIRST_NAME = "first_name";
  39. private static final String LAST_NAME = "last_name";
  40. private static final String AGE = "age";
  41. private static final String SEX = "sex";
  42.  
  43. // GAMES Table - column names
  44. private static final String USER_ID = "user_id";
  45. private static final String GAME_LABEL = "game_label";
  46. private static final String PLAYED_AT = "played";
  47. private static final String GAME_SCORE = "score";
  48. private static final String GOODCHOICE = "goodchoice";
  49. private static final String WRONGCHOICE = "wrongchoice";
  50.  
  51. // LEVEL Table - column names
  52. private static final String GAME_ID = "game_id";
  53. private static final String FIRST_NUMBER = "first_number";
  54. private static final String MARK = "mark";
  55. private static final String SECOND_NUMBER = "second_number";
  56. private static final String RESULT = "result";
  57. private static final String LEVEL_DURATION = "level_duration";
  58. private static final String LEVEL_SCORE = "level_score";
  59. private static final String DIRECTION = "direction";
  60. private static final String IMAGE_COMBINATION = "image_combination";
  61.  
  62. // Table Create Statements
  63. private static final String CREATE_TABLE_USER = "CREATE TABLE "
  64. + TABLE_USER + "("
  65. + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
  66. + GAME_TAG + " TEXT, "
  67. + FIRST_NAME + " TEXT, "
  68. + LAST_NAME + " TEXT, "
  69. + SEX + " TEXT, "
  70. + AGE + " INTEGER)";
  71.  
  72. private static final String CREATE_TABLE_GAME = "CREATE TABLE "
  73. + TABLE_GAME + "("
  74. + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
  75. + USER_ID + " INTEGER, "
  76. + GAME_LABEL + " TEXT, "
  77. + PLAYED_AT + " DATETIME, "
  78. + GAME_SCORE + " INTEGER, "
  79. + GOODCHOICE + " INTEGER, "
  80. + WRONGCHOICE + " INTEGER, "
  81. + " FOREIGN KEY (" + USER_ID + ") REFERENCES " + TABLE_USER + "(" + KEY_ID + "))";
  82.  
  83. private static final String CREATE_TABLE_LEVEL = "CREATE TABLE "
  84. + TABLE_LEVEL + "("
  85. + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
  86. + GAME_ID + " INTEGER, "
  87. + LEVEL_DURATION + " INTEGER, "
  88. + LEVEL_SCORE + " INTEGER, "
  89. + FIRST_NUMBER + " INTEGER, "
  90. + MARK + " TEXT, "
  91. + SECOND_NUMBER + " INTEGER, "
  92. + RESULT + " INTEGER, "
  93. + IMAGE_COMBINATION + " TEXT, "
  94. + DIRECTION + " TEXT, "
  95. + " FOREIGN KEY (" + GAME_ID + ") REFERENCES " + TABLE_GAME + "(" + KEY_ID + "))";
  96.  
  97. public DatabaseHelper(Context context)
  98. {
  99. super(context, DATABASE_NAME, null, DATABASE_VERSION);
  100. }
  101.  
  102. @Override
  103. public void onCreate(SQLiteDatabase sqLiteDatabase)
  104. {
  105. // creating required tables
  106. sqLiteDatabase.execSQL(CREATE_TABLE_USER);
  107. sqLiteDatabase.execSQL(CREATE_TABLE_GAME);
  108. sqLiteDatabase.execSQL(CREATE_TABLE_LEVEL);
  109. }
  110.  
  111. @Override
  112. public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1)
  113. {
  114. // on upgrade drop older tables
  115. sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_USER);
  116. sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_GAME);
  117. sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_LEVEL);
  118.  
  119. // create new tables
  120. this.onCreate(sqLiteDatabase);
  121. }
  122.  
  123. public boolean checkIfUserExists(String name)
  124. {
  125. SQLiteDatabase db = this.getReadableDatabase();
  126.  
  127. // String query = "SELECT " + GAME_TAG + " FROM " + TABLE_USER + " WHERE " + GAME_TAG + " =?";
  128. // String[] selection = {name} ;
  129. // Cursor c = db.rawQuery(query, selection);
  130.  
  131. String query2 = "SELECT * FROM " + TABLE_USER + " WHERE " + GAME_TAG + " = '" + name + "'";
  132. Cursor c = db.rawQuery(query2, null);
  133.  
  134. if (c.getCount() > 0)
  135. {
  136. c.close();
  137. db.close();
  138. return true;
  139. }
  140. else
  141. {
  142. c.close();
  143. db.close();
  144. return false;
  145. }
  146. }
  147.  
  148.  
  149. // CRUD for user table
  150. public boolean addUser(User user)
  151. {
  152. SQLiteDatabase db = this.getWritableDatabase();
  153.  
  154. ContentValues values = new ContentValues();
  155. values.put(GAME_TAG, user.getGameTag());
  156. values.put(FIRST_NAME, user.getFirstName());
  157. values.put(LAST_NAME, user.getLastName());
  158. values.put(SEX, "M");
  159. values.put(AGE, user.getAge());
  160.  
  161. long result = db.insert(TABLE_USER, null, values);
  162. db.close();
  163.  
  164. if (result == -1)
  165. {
  166. return false;
  167. }
  168. else
  169. {
  170. return true;
  171. }
  172. }
  173.  
  174. public List getAllUsers()
  175. {
  176. List users = new ArrayList();
  177. String query = "SELECT * FROM " + TABLE_USER + " ORDER BY " + KEY_ID;
  178.  
  179. Log.d(TAG, query);
  180.  
  181. SQLiteDatabase db = this.getReadableDatabase();
  182. Cursor c = db.rawQuery(query, null);
  183.  
  184. if (c.moveToFirst())
  185. {
  186. do
  187. {
  188. User user = new User();
  189. user.setId(c.getInt(0));
  190. user.setGameTag(c.getString(1));
  191. user.setFirstName(c.getString(2));
  192. user.setLastName(c.getString(3));
  193. user.setSex(c.getString(c.getColumnIndex(SEX)));
  194. user.setAge(c.getInt(c.getColumnIndex(AGE)));
  195.  
  196. // adding to the list
  197. users.add(user.getId() + " " + user.getGameTag() + " " + user.getFirstName() + " " + user.getLastName() + " " + user.getSex() + " " + user.getAge());
  198. } while (c.moveToNext());
  199. }
  200. db.close();
  201. return users;
  202. }
  203.  
  204. public User getUser(int user_id)
  205. {
  206. User user = new User();
  207. SQLiteDatabase db = this.getReadableDatabase();
  208.  
  209. String[] columns = {KEY_ID, GAME_TAG, FIRST_NAME, LAST_NAME};
  210.  
  211. String selection = KEY_ID + " = ?";
  212.  
  213. String[] selectionArgs = {String.valueOf(user_id)};
  214.  
  215. Cursor c = db.query(TABLE_USER, columns, selection, selectionArgs, null, null, null);
  216.  
  217. if (c != null)
  218. {
  219. c.moveToFirst();
  220. user.setId(c.getInt(0));
  221. user.setGameTag(c.getString(1));
  222. user.setFirstName(c.getString(2));
  223. user.setLastName(c.getString(3));
  224. }
  225. c.close();
  226. db.close();
  227. return user;
  228. }
  229.  
  230. public boolean updateUser(User user)
  231. {
  232. SQLiteDatabase db = this.getWritableDatabase();
  233.  
  234. ContentValues values = new ContentValues();
  235. values.put(GAME_TAG, user.getGameTag());
  236. values.put(FIRST_NAME, user.getFirstName());
  237. values.put(LAST_NAME, user.getLastName());
  238. values.put(SEX, user.getSex());
  239. values.put(AGE, user.getAge());
  240.  
  241. long result = db.update(TABLE_USER, values, KEY_ID + " = ?", new String[] {String.valueOf(user.getId())});
  242.  
  243. db.close();
  244. if(result == -1)
  245. {
  246. return false;
  247. }
  248. else
  249. {
  250. return true;
  251. }
  252. }
  253.  
  254. public void deleteUser(int user_id)
  255. {
  256.  
  257. }
  258.  
  259. public User getSignedUser(String gameTag)
  260. {
  261. User user = new User();
  262. SQLiteDatabase db = this.getReadableDatabase();
  263.  
  264. String[] columns = {KEY_ID, GAME_TAG, FIRST_NAME, LAST_NAME, SEX, AGE};
  265.  
  266. String selection = GAME_TAG + " = ?";
  267.  
  268. String[] selectionArgs = {gameTag};
  269.  
  270. Cursor c = db.query(TABLE_USER, columns, selection, selectionArgs, null, null, null);
  271.  
  272. if (c != null)
  273. {
  274. c.moveToFirst();
  275. user.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  276. user.setGameTag(c.getString(c.getColumnIndex(GAME_TAG)));
  277. user.setFirstName(c.getString(c.getColumnIndex(FIRST_NAME)));
  278. user.setLastName(c.getString(c.getColumnIndex(LAST_NAME)));
  279. user.setSex(c.getString(c.getColumnIndex(SEX)));
  280. user.setAge(c.getInt(c.getColumnIndex(AGE)));
  281. }
  282.  
  283. c.close();
  284. db.close();
  285. return user;
  286. }
  287.  
  288.  
  289. // CRUD for game table
  290. public boolean addGame(Game game)
  291. {
  292. SQLiteDatabase db = this.getWritableDatabase();
  293.  
  294. ContentValues values = new ContentValues();
  295. values.put(USER_ID, game.getUser_id());
  296. values.put(GAME_LABEL, game.getLabel());
  297. values.put(PLAYED_AT, game.getPlayed());
  298. values.put(GAME_SCORE, game.getScore());
  299. values.put(GOODCHOICE, game.getGoodchoice());
  300. values.put(WRONGCHOICE, game.getWrongchoice());
  301.  
  302. long result = db.insert(TABLE_GAME, null, values);
  303. db.close();
  304.  
  305. if (result == -1)
  306. {
  307. return false;
  308. }
  309. else
  310. {
  311. return true;
  312. }
  313. }
  314.  
  315. public List<Game> getAllGames()
  316. {
  317. List games = new ArrayList();
  318. String query = "SELECT * FROM " + TABLE_GAME + " ORDER BY " + KEY_ID;
  319.  
  320. Log.d(TAG, query);
  321.  
  322. SQLiteDatabase db = this.getReadableDatabase();
  323. Cursor c = db.rawQuery(query, null);
  324.  
  325. if (c.moveToFirst())
  326. {
  327. do
  328. {
  329. Game game = new Game();
  330. game.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  331. game.setLabel(c.getString(c.getColumnIndex(GAME_LABEL)));
  332. /***
  333. * TODO: TU POKRAČOVAŤ
  334. */
  335. games.add(game.getId() + " " + game.getLabel());
  336. } while (c.moveToNext());
  337. }
  338. db.close();
  339. return games;
  340. }
  341.  
  342. public List<Game> getAllGamesForSpecificUser(long user_id)
  343. {
  344. Log.d(TAG, "HLADAM HRY PRE ID: " + user_id);
  345.  
  346. List<Game> games = new ArrayList();
  347.  
  348. SQLiteDatabase db = getReadableDatabase();
  349.  
  350. String query = "SELECT * FROM " + TABLE_GAME + " WHERE " + USER_ID + " = '" + user_id + "'";
  351. Cursor c = db.rawQuery(query, null);
  352.  
  353. if (c.moveToFirst())
  354. {
  355. do
  356. {
  357. Game game = new Game();
  358. game.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  359. game.setLabel(c.getString(c.getColumnIndex(GAME_LABEL)));
  360. game.setPlayed(c.getString(c.getColumnIndex(PLAYED_AT)));
  361. game.setScore(c.getInt(c.getColumnIndex(GAME_SCORE)));
  362. game.setGoodchoice(c.getInt(c.getColumnIndex(GOODCHOICE)));
  363. game.setWrongchoice(c.getInt(c.getColumnIndex(WRONGCHOICE)));
  364. games.add(game);
  365.  
  366. } while (c.moveToNext());
  367. c.close();
  368. }
  369. db.close();
  370. return games;
  371. }
  372.  
  373. /*public Game getGame(int game_id)
  374. {
  375.  
  376. }*/
  377.  
  378. public Game getLastGame()
  379. {
  380. Game game = new Game();
  381. SQLiteDatabase db = this.getReadableDatabase();
  382.  
  383. String query = "SELECT * FROM " + TABLE_GAME + " ORDER BY " + KEY_ID + " DESC LIMIT 1";
  384.  
  385. Cursor c = db.rawQuery(query, null);
  386.  
  387. if (c.moveToFirst())
  388. {
  389. game.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  390. game.setUser_id(c.getInt(c.getColumnIndex(USER_ID)));
  391. game.setLabel(c.getString(c.getColumnIndex(GAME_LABEL)));
  392. game.setScore(c.getInt(c.getColumnIndex(GAME_SCORE)));
  393. game.setGoodchoice(c.getInt(c.getColumnIndex(GOODCHOICE)));
  394. game.setWrongchoice(c.getInt(c.getColumnIndex(WRONGCHOICE)));
  395. }
  396. return game;
  397. }
  398.  
  399. public boolean updateGame(Game game)
  400. {
  401. SQLiteDatabase db = this.getWritableDatabase();
  402.  
  403. ContentValues values = new ContentValues();
  404. values.put(GAME_SCORE, game.getScore());
  405. values.put(GOODCHOICE, game.getGoodchoice());
  406. values.put(WRONGCHOICE, game.getWrongchoice());
  407.  
  408. long result = db.update(TABLE_GAME, values, KEY_ID + " = ?", new String[] {String.valueOf(game.getId())});
  409.  
  410. db.close();
  411. if (result == -1)
  412. {
  413. return false;
  414. }
  415. else
  416. {
  417. return true;
  418. }
  419. }
  420.  
  421. public void deleteLastGame(String name)
  422. {
  423. SQLiteDatabase db = this.getWritableDatabase();
  424. Game game = getLastGame();
  425. Log.d(TAG, "VYMAZAVM POSLEDNU HRU: " + game.getId() + " " + name);
  426. db.delete(TABLE_GAME, KEY_ID + " = " + game.getId(), null);
  427. }
  428.  
  429. public int getBestScoreFromGame(String gameLabel, long user_id)
  430. {
  431. Game game = new Game();
  432. SQLiteDatabase db = getReadableDatabase();
  433.  
  434. String query = "SELECT * FROM " + TABLE_GAME + " WHERE " + GAME_LABEL + " = '" + gameLabel + "' AND " + USER_ID + " = " + user_id + " ORDER BY " + GAME_SCORE + " DESC";
  435. Cursor c = db.rawQuery(query, null);
  436.  
  437. if (c.moveToFirst())
  438. {
  439. game.setScore(c.getInt(c.getColumnIndex(GAME_SCORE)));
  440. c.close();
  441. }
  442.  
  443. db.close();
  444. return game.getScore();
  445. }
  446.  
  447. public int getTotalPlayedGames(String gameLabel, long user_id)
  448. {
  449. int totalPlayedGames = 0;
  450. SQLiteDatabase db = getReadableDatabase();
  451.  
  452. String query = "SELECT COUNT(*) FROM " + TABLE_GAME + " WHERE " + GAME_LABEL + " = '" + gameLabel + "' AND " + USER_ID + " = " + user_id;
  453. Cursor c = db.rawQuery(query, null);
  454.  
  455. if (c.moveToFirst())
  456. {
  457. totalPlayedGames = c.getInt(c.getColumnIndex("COUNT(*)"));
  458. c.close();
  459. }
  460. db.close();
  461. return totalPlayedGames;
  462. }
  463.  
  464. public int getSumOfGoodchoicesInGame(String gameLabel, long user_id)
  465. {
  466. int totalGoodchoices = 0;
  467. SQLiteDatabase db = getReadableDatabase();
  468.  
  469. String query = "SELECT SUM(" + GOODCHOICE + ") FROM " + TABLE_GAME + " WHERE " + GAME_LABEL + " = '" + gameLabel + "' AND " + USER_ID + " = " + user_id;
  470.  
  471. Cursor c = db.rawQuery(query, null);
  472.  
  473. if (c.moveToFirst())
  474. {
  475. totalGoodchoices = c.getInt(c.getColumnIndex("SUM(" + GOODCHOICE + ")"));
  476. c.close();
  477. }
  478.  
  479. db.close();
  480. return totalGoodchoices;
  481. }
  482.  
  483. public int getSumOfWrongchoicesInGame(String gameLabel, long user_id)
  484. {
  485. int totalGoodchoices = 0;
  486. SQLiteDatabase db = getReadableDatabase();
  487.  
  488. String query = "SELECT SUM(" + WRONGCHOICE + ") FROM " + TABLE_GAME + " WHERE " + GAME_LABEL + " = '" + gameLabel + "' AND " + USER_ID + " = " + user_id;
  489.  
  490. Cursor c = db.rawQuery(query, null);
  491.  
  492. if (c.moveToFirst())
  493. {
  494. totalGoodchoices = c.getInt(c.getColumnIndex("SUM(" + WRONGCHOICE + ")"));
  495. c.close();
  496. }
  497.  
  498. db.close();
  499. return totalGoodchoices;
  500. }
  501.  
  502. //CRUD for level table
  503. public boolean addLevel(Level level)
  504. {
  505. SQLiteDatabase db = this.getWritableDatabase();
  506.  
  507. ContentValues values = new ContentValues();
  508. values.put(GAME_ID, level.getGame_id());
  509. values.put(LEVEL_DURATION, level.getLevel_duration());
  510. values.put(LEVEL_SCORE, level.getLevel_score());
  511. values.put(FIRST_NUMBER, level.getFirst_number());
  512. values.put(MARK, level.getMark());
  513. values.put(SECOND_NUMBER, level.getSecond_number());
  514. values.put(RESULT, level.getResult());
  515. values.put(DIRECTION, level.getDirection());
  516.  
  517. long result = db.insert(TABLE_LEVEL, null, values);
  518. db.close();
  519.  
  520. if (result == -1)
  521. {
  522. return false;
  523. }
  524. else
  525. {
  526. return true;
  527. }
  528. }
  529.  
  530. // public List getAllLevels()
  531. // {
  532. //
  533. // }
  534. //
  535. // public boolean updateLevel()
  536. // {
  537. //
  538. // }
  539. //
  540. // public boolean deleteLevel()
  541. // {
  542. //
  543. // }
  544.  
  545. public String getNameOfPlayer(long game_id)
  546. {
  547. SQLiteDatabase db = getReadableDatabase();
  548. String query = "SELECT * FROM " + TABLE_USER + " WHERE " + KEY_ID + " = '" + game_id + "'";
  549. Cursor c = db.rawQuery(query, null);
  550.  
  551. String name = null;
  552.  
  553. if (c.moveToFirst())
  554. {
  555. name = c.getString(c.getColumnIndex(GAME_TAG));
  556. c.close();
  557. }
  558. db.close();
  559.  
  560. return name;
  561. }
  562.  
  563. public List getAllLevelsForMathGame(long game_id, String gameLabel)
  564. {
  565. Log.d(TAG, "HLADAM levely PRE ID: " + game_id + " Kategoria hry: " + gameLabel);
  566.  
  567. List levels = new ArrayList();
  568. SQLiteDatabase db = getReadableDatabase();
  569.  
  570. String query = "SELECT * FROM " + TABLE_LEVEL + " WHERE " + GAME_ID + " = '" + game_id + "'";
  571.  
  572. Cursor c = db.rawQuery(query, null);
  573. int i = 1;
  574.  
  575.  
  576. if (c.moveToFirst())
  577. {
  578. if (gameLabel.equals(GameTitles.imagesGame))
  579. {
  580. do
  581. {
  582. Level level = new Level();
  583. level.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  584. level.setLevel_duration(c.getInt(c.getColumnIndex(LEVEL_DURATION)));
  585. level.setLevel_score(c.getInt(c.getColumnIndex(LEVEL_SCORE)));
  586. level.setDirection(c.getString(c.getColumnIndex(DIRECTION)));
  587.  
  588. levels.add(i++ + ".\nKombináciu našiel za: " + level.getLevel_duration()
  589. + "\nSkóre za nájdenú kombináciu: " + level.getLevel_score()
  590. + "\nSmer nájdenej kombinácie: " + level.getDirection());
  591. } while (c.moveToNext());
  592. }
  593. else if (gameLabel.equals(GameTitles.additionGame) || gameLabel.equals(GameTitles.additionAndSubtractionGame) || gameLabel.equals(GameTitles.subtractionGame))
  594. {
  595. do
  596. {
  597. Level level = new Level();
  598. level.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  599. level.setFirst_number(c.getInt(c.getColumnIndex(FIRST_NUMBER)));
  600. level.setMark(c.getString(c.getColumnIndex(MARK)));
  601. level.setSecond_number(c.getInt(c.getColumnIndex(SECOND_NUMBER)));
  602. level.setResult(c.getInt(c.getColumnIndex(RESULT)));
  603. level.setLevel_duration(c.getInt(c.getColumnIndex(LEVEL_DURATION)));
  604. level.setLevel_score(c.getInt(c.getColumnIndex(LEVEL_SCORE)));
  605.  
  606. levels.add(i++ + "."
  607. + "\nPríklad: " + level.getFirst_number() + " " + level.getMark() + " " + level.getSecond_number() + " = " + level.getResult()
  608. + "\nČas za ktorý ho vypočítal: " + level.getLevel_duration()
  609. + "\nSkóre za príklad: " + level.getLevel_score());
  610. } while (c.moveToNext());
  611. }
  612. else if (gameLabel.equals(GameTitles.ladybugGame))
  613. {
  614. do
  615. {
  616. Level level = new Level();
  617. level.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  618. level.setLevel_duration(c.getInt(c.getColumnIndex(LEVEL_DURATION)));
  619.  
  620. levels.add(i++ + ".\nPlochu vyriešil za: " + level.getLevel_duration());
  621. } while (c.moveToNext());
  622. }
  623. else if (gameLabel.equals(GameTitles.quickSortGame))
  624. {
  625. levels.add("Táto hra zatiaľ nezaznamenáva žiadne dodatočné údaje.");
  626. }
  627. else if (gameLabel.equals(GameTitles.squareAdditionGame))
  628. {
  629. do
  630. {
  631. Level level = new Level();
  632. level.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  633. level.setLevel_duration(c.getInt(c.getColumnIndex(LEVEL_DURATION)));
  634. level.setLevel_score(c.getInt(c.getColumnIndex(LEVEL_SCORE)));
  635.  
  636. levels.add(i++ + ".\nPlochu vyriešil za: " + level.getLevel_duration()
  637. + "\nSkóre za vypočítanú plochu: " + level.getLevel_score());
  638. } while (c.moveToNext());
  639. }
  640. else if (gameLabel.equals(GameTitles.lacesGame))
  641. {
  642. do
  643. {
  644. Level level = new Level();
  645. level.setId(c.getInt(c.getColumnIndex(KEY_ID)));
  646. level.setLevel_duration(c.getInt(c.getColumnIndex(LEVEL_DURATION)));
  647. level.setLevel_score(c.getInt(c.getColumnIndex(LEVEL_SCORE)));
  648.  
  649. levels.add(i++ + ".\nPlochu vyriešil za: " + level.getLevel_duration()
  650. + "\nSkóre za vyriešenú plochu: " + level.getLevel_score());
  651. } while (c.moveToNext());
  652. }
  653. }
  654.  
  655. c.close();
  656. db.close();
  657. return levels;
  658. }
  659. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement