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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:21:36+00:00 2026-05-20T16:21:36+00:00

I get my data out of my db with the following code: private void

  • 0

I get my data out of my db with the following code:

private void fillData() {
        cursor = mDbAdapter.fetchAllSubjects();
        startManagingCursor(cursor);

        String[] from = new String[] { DatabaseAdapter.KEY_TITLE, DatabaseAdapter.KEY_LECTURER, DatabaseAdapter.KEY_BEGIN };
        int[] to = new int[] { R.id.title, R.id.lecturer, R.id.time };

        // Now create an array adapter and set it to display using our row
        SimpleCursorAdapter subjects = new SimpleCursorAdapter(this, R.layout.subject_row, cursor, from, to);

        setListAdapter(subjects);
    }

Now my problem is, that I want to add 3 other columns from my db and want to get the following:

  • “(“+DatabaseAdapter.KEY_TYPE+”) “+DatabaseAdapter.KEY_TITLE
  • DatabaseAdapter.KEY_LECTURER
  • new Date(DatabaseAdapter.KEY_BEGIN)
  • new Date(DatabaseAdapter.KEY_END)
    –> these two should be in one TextView in the way dd.MM. HH:mm (this is from BEGIN) – HH:mm (this is from END)

I don’t know how I’m able to do that – please help me 🙂

  • 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-20T16:21:37+00:00Added an answer on May 20, 2026 at 4:21 pm

    Ok I finally figured out what you really wanted.

    Instead of using “SimpleCursorAdapter” directly, you can create your own Cursor adapter, inside which you can mainipulate the data as you want.
    Create a new Adapter “SubjectsAdapter.java”. In this Adapter you will override the “bindView” and “newView”. This allows us to apply a view to the cursor. But before doing so, gives us the opportunity to change the data from the cursor.

    This will give you an idea what has to be done.

        private void fillData() 
        {
            cursor = mDbAdapter.fetchAllSubjects();
            startManagingCursor(cursor);
    
    
            SubjectsAdapter subjectsAdapter = new SubjectsAdapter(this, cursor);
            setListAdapter(subjectsAdapter);
        }
    
    
    //SubjectsAdapter.java - make changes to fix bugs/compilation errors. This is untested.
    public class SubjectsAdapter extends ResourceCursorAdapter 
    {
        public SubjectsAdapter(Context context, Cursor cur) {
            super(context, R.layout.subject_row, cur);
        }
    
        @Override
        public View newView(Context context, Cursor cur, ViewGroup parent) 
        {
             LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
             return li.inflate(R.layout.subject_row, parent, false);
        }
    
        @Override
        public void bindView(View view, Context context, Cursor cursor) 
        {           
            TextView titleText = (TextView)view.findViewById(R.id.title);
              titleText.setText(cursor.getString(cursor.getColumnIndex(DatabaseAdapter.KEY_TITLE)));
    
            //You can add code to retrieve other columns here.
    
            //This is where you retrieve the date in long format from cursor, convert it to a required format, and then using it.
            TextView beginTimeText = (TextView)view.findViewById(R.id.time);            
            Long lBeginDate = cursor.getLong(cursor.getColumnIndex(DatabaseAdapter.KEY_BEGIN));
            String sBeginDate = getFormattedDate(lBeginDate);           
            beginTimeText.setText(sBeginDate);
       }
    
        private String getFormattedDate(Long lDate)
        {
             SimpleDateFormat smdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a");       
            String sDate = smdf.format( lDate ));
            return sDate;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.