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 6837423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:28:32+00:00 2026-05-26T23:28:32+00:00

I am getting the data from sqlite database and trying to display it in

  • 0

I am getting the data from sqlite database and trying to display it in CustomeListView But it is displaying some items example i can see six items in my listView at a time then it is showing six items when i scroll it, it will repeatedly show same items HERE IS MY CODE

Here i am querying from database

public ArrayList<GetEmailFromDatabase> emails_From_Database() {
    SQLiteDatabase db = helper.getReadableDatabase();
    try {
        GetEmailFromDatabase gefd;
        ArrayList<GetEmailFromDatabase> results = new ArrayList<GetEmailFromDatabase>();
        Cursor c = db.rawQuery("select * from Emailreceived", null);
        if (c.getCount() > 0) {
            int i=0;
            c.moveToPosition(i);
            do {
                gefd = new GetEmailFromDatabase();
                gefd.setMessage_No(c.getInt(c.getColumnIndex("_Id")));
                gefd.setFrom(c.getString(c.getColumnIndex("EmailFrom")));
                gefd.setDate(c.getString(c.getColumnIndex("EmailDate")));
                gefd.setSubject(c.getString(c.getColumnIndex("Subject")));
                results.add(gefd);
                gefd = null;
                i++;
            } while (c.moveToPosition(i));
            c.close();
        }
        return results;
    } finally {
        if (db != null)
            db.close();
        }
}

This is my listActivity with custom list

public class Email_listActivity extends MenuOptions{

//Database getEmails = new Database(getApplicationContext());
String items[]={"red","white","Black","green","brown","yellow","blue","pink","orange"}; 
Database database;
String mData;

ArrayList<GetEmailFromDatabase> emailResults;

Database db1;
private EmailListFeedAdapter emailListFeedAdapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.email_list_main);

    emailResults = new ArrayList<GetEmailFromDatabase>();

    emailListFeedAdapter = new EmailListFeedAdapter(this, R.layout.email_listview_row, emailResults);
    setListAdapter(this.emailListFeedAdapter);

        getResults();
        if(emailResults != null && emailResults.size() > -1){
            emailListFeedAdapter.notifyDataSetChanged();
        for(int i=0;i< emailResults.size();i++){
            emailListFeedAdapter.add( emailResults.get(i));
            Log.e("%%%%%%%%%%%%%%%%%%%", "emailResults -------->"+emailListFeedAdapter.areAllItemsEnabled());
        }
        }
}
@Override

protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    int pos = position;
    String s = (String) ((TextView) v.findViewById(R.id.item_number)).getText();
    database = new Database(getApplicationContext());
    mData = database.getDate(s);

    Intent i = new Intent(Email_listActivity.this, EmailWebView.class);
    i.putExtra("webData", mData);
    startActivity(i);
    Log.e("$$$$$$$$$$$$", "POSITION--------->"+position+"   View-------->"+v);
    Toast.makeText(getApplicationContext(), "Hello"+v, Toast.LENGTH_SHORT).show();
}
public void getResults(){
    db1 = new Database(getBaseContext());
    emailResults = new ArrayList<GetEmailFromDatabase>();
    //ArrayList<GetEmailFromDatabase> fromdatabase = db1.emails_From_Database();
    emailResults = db1.emails_From_Database();

}

public class EmailListFeedAdapter extends ArrayAdapter<GetEmailFromDatabase>{

    private ArrayList<GetEmailFromDatabase> itemss;
    public EmailListFeedAdapter(Context context, int textViewResourceId, ArrayList<GetEmailFromDatabase> items) {
        super(context, textViewResourceId, items);
        this.itemss = items; 
    }

    @Override
    public View getView(int position, View emailView, ViewGroup parent) {
        if(emailView == null){
        LayoutInflater inflater= (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        emailView= inflater.inflate(R.layout.email_listview_row, null);

        GetEmailFromDatabase o = itemss.get(position);
        if(o!=null){
        TextView  messageNo = (TextView)emailView.findViewById(R.id.item_number);
        TextView  subject= (TextView)emailView.findViewById(R.id.emaillistrow_txt_partofemail);
        TextView  sender= (TextView)emailView.findViewById(R.id.emaillistrow_txt_sender);
        TextView  datetime= (TextView)emailView.findViewById(R.id.emaillistrow_txt_datetime);
        ImageView icon= (ImageView)emailView.findViewById(R.id.emaillistrow_icon_indicator);
        icon.setImageResource(R.drawable.y_icon);

        if(messageNo!=null){
        messageNo.setText(Integer.toString(o.getMessage_No()));
        }
        if(subject!=null){
        subject.setText(o.getSubject());
        }
        if(sender!=null){
        sender.setText(o.getFrom());
        }
        if(datetime!=null){
        datetime.setText(o.getDate());
        }
        }
      }
      return emailView;

    }

}

}
  • 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-05-26T23:28:32+00:00Added an answer on May 26, 2026 at 11:28 pm

    Ok, can you replace your adapter class’s getView() method with mine,

    @Override
        public View getView(int position, View emailView, ViewGroup parent) {
            if(emailView == null){
            LayoutInflater inflater= (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            emailView= inflater.inflate(R.layout.email_listview_row, null);
            }
            GetEmailFromDatabase o = itemss.get(position);
            if(o!=null){
            TextView  messageNo = (TextView)emailView.findViewById(R.id.item_number);
            TextView  subject= (TextView)emailView.findViewById(R.id.emaillistrow_txt_partofemail);
            TextView  sender= (TextView)emailView.findViewById(R.id.emaillistrow_txt_sender);
            TextView  datetime= (TextView)emailView.findViewById(R.id.emaillistrow_txt_datetime);
            ImageView icon= (ImageView)emailView.findViewById(R.id.emaillistrow_icon_indicator);
            icon.setImageResource(R.drawable.y_icon);
    
            if(messageNo!=null){
            messageNo.setText(Integer.toString(o.getMessage_No()));
            }
            if(subject!=null){
            subject.setText(o.getSubject());
            }
            if(sender!=null){
            sender.setText(o.getFrom());
            }
            if(datetime!=null){
            datetime.setText(o.getDate());
            }
            }
    
          return emailView;
    
        }
    

    after replacing let me know what happen..

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

Sidebar

Related Questions

I am trying get the data from my database but i am not getting
In my project I am getting data from sqlite database and setting that data
I have a little problem with getting all data from SQLite database and showing
how can i getting data from listbox in second form named listform while i
I'm getting some data from the web service and saving it in the core
I am getting some junk data returned from a ToString() call on a DateTime
I am trying to insert a data into SQLite database using Python. INSERT INTO
I'm trying to select data from the database and I have the following code
I'm trying to use DbLinq with a SQLite database, but I'm running into a
Ok, so the issue is coming from trying to pull data from a sqlite

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.