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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:54:29+00:00 2026-06-09T23:54:29+00:00

public class ABC extends ListActivity { static final ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); @Override

  • 0
public class ABC extends ListActivity {
static final ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.abc_list);

    SimpleAdapter adapter = new SimpleAdapter(
            this,
            list,
            R.layout.abc_list_row,
            new String[] {"AAA","BBB","CCC"},
            new int[] {R.id.aa,R.id.bb, R.id.cc,}
            );

    add();
    setListAdapter(adapter);  
}

   private void add() {        

    DatabaseA databaseHelper = new DatabaseA(this);
    SQLiteDatabase db = databaseHelper.getReadableDatabase();

    Cursor c= db.rawQuery("select * from data", null);
    HashMap<String,String> temp = new HashMap<String,String>();  

    while(c.moveToNext()){
        Log.d("Debug", c.getString(2));
        temp.put("AAA", c.getString(1));
        temp.put("BBB", c.getString(2));
        temp.put("CCC", c.getString(3));
        list.add(temp);
    } 

    c.close();
    db.close();

    for (Map.Entry<String, String> entry : temp.entrySet()) {
        String xx= entry.getKey();
        String yy = entry.getValue();
        Log.d("data", xx+" : "+yy);
    }
}

My Logcat:

 D/Debug(657): New york
 D/Debug(657): New moon
 D/data(657): AAA : Aug 20, 2012 3:57:02 PM
 D/data(657): BBB : New moon
 D/data(657): CCC : Title

My problem is it always left out the first data from sqlite in this list. Besides, everytime i press a button to view this list, it will add those data into this list although they are already exist. I just want to view those data in sqlite in list form. Any way to solve this. Thanks.

  • 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-09T23:54:31+00:00Added an answer on June 9, 2026 at 11:54 pm

    You need to create your Map inside your while loop

    while(c.moveToNext()){
        Map<String,String> temp = new HashMap<String,String>();  
        Log.d("Debug", c.getString(2));
        temp.put("AAA", c.getString(1));
        temp.put("BBB", c.getString(2));
        temp.put("CCC", c.getString(3));
        list.add(temp);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
public class abc<X extends Z> implements Iterable<X> { protected ArrayList<X> list; public Iterator<X> iterator()
Consider this case: public Class1 { public static final String ONE = ABC; public
package test.abc; public abstract class Base { ... public static class ChildInner extends Base
I have :- Class Abc extends Activity(){ private ActivityManager am; private List<RunningAppProcessInfo> rList; @Override
I have a class which extends AsyncTask public class SendJSONArray2Server extends AsyncTask<String, Void, HttpResponse>
My model class is like this: Public class abc { public string p1 get;
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
public abstract class Abc<T> { public abstract void f1(T a); } abstract class Def<T>
What am I missing here? public class abc extends JFrame { private JButton save

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.