Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String[] getCategoryAndProgress(String subject) {
- DataBaseHelper dbHelperCount = new DataBaseHelper(this);
- dbHelperCount = new DataBaseHelper(this);
- int count = 0;
- try {
- dbHelperCount.openDataBase();
- Cursor cursor = dbHelperCount.getCategoryProcess(subject);
- if (cursor != null) {
- if (cursor.moveToFirst()) {
- do {
- count = cursor.getInt(cursor.getColumnIndex("count(*)"));
- } while (cursor.moveToNext());
- }
- }
- cursor.close();
- }
- catch(SQLException sqle) {throw sqle;}
- finally {dbHelperCount.close();}
- DataBaseHelper dbHelperProgress = new DataBaseHelper(this);
- dbHelperProgress = new DataBaseHelper(this);
- String category = "";
- int correct = 0;
- int attempted = 0;
- double score = 0.0;
- String[] returnString = new String[count];
- try {
- dbHelperProgress.openDataBase();
- Cursor cursor = dbHelperProgress.getCategoryProcess(subject);
- if (cursor != null) {
- if (cursor.moveToFirst()) {
- do {
- category = cursor.getString(cursor.getColumnIndex("category"));
- attempted = cursor.getInt(cursor.getColumnIndex("attempted"));
- correct = cursor.getInt(cursor.getColumnIndex("correct"));
- score = ((double)correct/(double)attempted)*100;
- returnString[count] = {category, Double.toString(score)};
- } while (cursor.moveToNext());
- }
- }
- cursor.close();
- }
- catch(SQLException sqle) {throw sqle;}
- finally {dbHelperProgress.close();}
- return returnString;
- }
Add Comment
Please, Sign In to add comment