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

  • SEARCH
  • Home
  • 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 8821891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:57:58+00:00 2026-06-14T05:57:58+00:00

I make application and I have a problem with database again. I made two

  • 0

I make application and I have a problem with database again.
I made two buttons – previous button and next button.
Next button is work, but after click previous button program doesn’t diplay record in textview. Why?
First I click nest button all work then I click previous button and “cursor” go to previous record but doesn’t display record in textview.

I solved my problem.
I deleted methods: getNextdata() and getPrevData.

Now my code is:

Galeria.java:

public class Galeria extends Activity {

    public static long record = 1;
    PrzyslowiaArabskie info = new PrzyslowiaArabskie(this);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.galeria);

        TextView tv = (TextView) findViewById(R.id.editText1);
        info.open();
        int irec = info.policz_rec();
        Toast.makeText(getApplicationContext(), " ilość przysłów w bazie " + irec, Toast.LENGTH_SHORT).show();
        String data = info.getData(record);
        info.close();
        tv.setText(data);


        Button bNastepny = (Button) findViewById(R.id.next);
        bNastepny.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                TextView tv = (TextView) findViewById(R.id.editText1);
                info.open();
                record++;
                String data = info.getData(record);
                info.close();
                tv.setText(data);

                }
        });
        Button bPoprzedni = (Button) findViewById(R.id.prev);
        bPoprzedni.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                TextView tv = (TextView) findViewById(R.id.editText1);
                info.open();
                record--;
                String data = info.getData(record);
                info.close();
                tv.setText(data);

                }
        });
    }
}

My method in DB Helper class:

public String getData(long record) {
        // TODO Auto-generated method stub
        record = Galeria.record;
        String[] columns = new String[] { KEY_ID, KEY_PRZYSLOWIE};
        Cursor c = myDatabase.query(TABLE_NAME, columns, KEY_ID + "=" + record, null, null, null, null);
        if (c != null) {
             c.moveToFirst(); 
             String data = c.getString(1);
             return data;
    }
        return null;


}

And my all buttons (next and prefious) work. Thank you for help.

  • 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-14T05:57:59+00:00Added an answer on June 14, 2026 at 5:57 am

    without running your code, are you sure that you didn’t forget to put:

    info.open();

    and

    info.close();

    in your previous button’s onclick listener?

    such as:

    Button bPoprzedni = (Button) findViewById(R.id.prev);
        bPoprzedni.setOnClickListener(new View.OnClickListener() {
    
            public void onClick(View v) {
                // TODO Auto-generated method stub
                TextView tv = (TextView) findViewById(R.id.editText1);
                info.open();
                record--;
                String data = info.getPrevData(record);
                info.close();
                tv.setText(data);
    
            }
        });
    

    ==================================

    if that doesn’t solve the problem, does your logcat indicate any errors? if not, are you absolutely sure that you are retrieving a string from your getPrevData(record) method? you can check this by doing something like:

    String data = info.getPrevData(record);
    Log.d("bPoprzedni", data);
    

    and if data is not showing in LogCat, then you know you’re not getting it from the database correctly.

    if data is showing up in LogCat, then you narrowed the problem down, and we can help you with that part easily 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have to make an application where i need to play two video simultaniously,on
I make a java application using netbeans that connect to database , but i
I have an application that use sqlite as local database, but I have problems
i have an application where i order make a query to my database with
I just want to know that can i make an application which have some
I have been using the storyboard to make an application and currently there are
I want to make an application in C or C++ which have to monitor
In general, is it better to have a web application make lots of calls
I have an application that I make a call to a DLL function that
I have an application where I would like to make my reducers (I have

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.