Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:37:06+00:00 2026-06-02T08:37:06+00:00

I have two table TABLE_EXAM and TABLE_QUESTION. I fetch record using following code but

  • 0

I have two table “TABLE_EXAM” and “TABLE_QUESTION”. I fetch record using following code
but it show only one record. I need to show all record but one by one after clicking on Next button.Please give me some reference or hint.
I don’t understand how to fetch record one by one by clicking on Next Button.
Thanks in Advance.

AppearingExamActivity.java

db=new MySQLiteHelper(getBaseContext());
        db.getWritableDatabase();
        examId=db.getExamId(profile);

        final List<ObjectiveWiseQuestion> QuestionWiseProfile= db.getOneQuestion(examId);       

        for (final ObjectiveWiseQuestion cn : QuestionWiseProfile)
        {   
            db=new MySQLiteHelper(getBaseContext());
            db.getWritableDatabase();

            //db.close();
            txtQuestion.setText(cn.getQuestion());
            optionA.setText(cn.getOptionA());
            optionB.setText(cn.getOptionB());
            optionC.setText(cn.getOptionC());
            optionD.setText(cn.getOptionD());   
            correctOption=cn.getCorrectOption();

        }

    }
    btnNext.setOnClickListener(new View.OnClickListener()
    {           
        @Override
        public void onClick(View v)
        {
            try
            {
                db=new MySQLiteHelper(getBaseContext());
                db.getWritableDatabase();
                owq.getCorrectAnswer();
                owq.setExamId(examId);
                //owq.getExamId();
                owq.getQuestionId();
                db.addResultDetails(owq);
                db.close();

            }
            catch(Exception e)
            {
                e.printStackTrace();
            }

        }
    });

MySQLiteHelper.java

public List<ObjectiveWiseQuestion> getOneQuestion(int examId)
{
   // long index = 0;
    List<ObjectiveWiseQuestion>LocwiseProfileList=new ArrayList<ObjectiveWiseQuestion>();
     db = getReadableDatabase();


     String selectQuery=("select * from question where exam_id ='"+ examId +"'");
        Cursor cursor = db.rawQuery(selectQuery, null);


    if (cursor.moveToFirst())
    {
        do {
            ObjectiveWiseQuestion owq= new ObjectiveWiseQuestion();

            owq.setQuestionId(cursor.getInt(0));
            owq.setExamId(cursor.getInt(1));
            owq.setQuestion(cursor.getString(2));
            owq.setOptionA(cursor.getString(3));
            owq.setOptionB(cursor.getString(4));
            owq.setOptionC(cursor.getString(5));
            owq.setOptionD(cursor.getString(6));
            owq.setCorrectOption(cursor.getString(7));

            LocwiseProfileList.add(owq);
        } while(cursor.moveToNext());
        db.close();

    }


    return LocwiseProfileList;
}

how to do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:37:07+00:00Added an answer on June 2, 2026 at 8:37 am

    Finally I got answer… I count number of record and only decrement it by 1. If i have 10 record then i set counter=10 and simply decrement it by 1 on each next click.
    Here is simple function which help me.

    public List<ObjectiveWiseQuestion> getOneByOneQuestion(int examId, int questionId)
    {      
        List<ObjectiveWiseQuestion>LocwiseProfileList=new ArrayList<ObjectiveWiseQuestion>();
         db = getWritableDatabase(); 
    
         String selectQuery=("select * from question where exam_id ='" + examId + "' and question_id ='" + questionId +"'" );
            Cursor cursor = db.rawQuery(selectQuery, null);
    
    
        if (cursor.moveToFirst())
        {
            do {
                ObjectiveWiseQuestion owq= new ObjectiveWiseQuestion();
    
                owq.setQuestionId(cursor.getInt(0));
                owq.setExamId(cursor.getInt(1));
                owq.setQuestion(cursor.getString(2));
                owq.setOptionA(cursor.getString(3));
                owq.setOptionB(cursor.getString(4));
                owq.setOptionC(cursor.getString(5));
                owq.setOptionD(cursor.getString(6));
                owq.setCorrectOption(cursor.getString(7));
    
                LocwiseProfileList.add(owq);
            } while(cursor.moveToNext());
            cursor.moveToFirst();
            db.close();
    
        }
    
    
        return LocwiseProfileList;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two table in mysql named rootpath with only one field 'root' and
I have two table i want to add one condition while using LEFT OUTER
I have two table to be joined using hbm file. The scenario is as
I have two table. OLDTABLE and NEWTABLE. I need to insert some data from
I have two table in my database. One called person and one called team.
I have two table (TABLE_EXAM,TABLE_RESULT). Here is value of my TABLE_RESULT. result_id exam_id question_id
I have two table functions that return a single column each. One function is
I have two table cpuinfo and jobinfo. I want to create report using both
I have two table and I need to copy the data across from SRCServiceUsers
I am using EF (Framework 3.5 SP1) and have a simple two table demo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.