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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:06:58+00:00 2026-05-16T21:06:58+00:00

In my application, after the user presses the appropriate button, an activity starts that

  • 0

In my application, after the user presses the appropriate button, an activity starts that creates a database with one table with two columns. The thing I can’t seem to get is: I would like one of the columns to automatically fill with the days of the week so that when I return a cursor over the database for the listActivity, the days are shown. I can get the database to build but I can’t seem to get the column to fill with the days. I tried this

public void installDays()
{
   String[] day = new String[7];;
   ContentValues initialValues = new ContentValues();
   day[0] = "Monday";
   day[1] = "Tuesday";
   day[2] = "Wednesday";
   day[3] = "Thursday";
   day[4] = "Friday";
   day[5] = "Saturday";
   day[6] = "Sunday";
   for(int i = 0; i < 7; i++)
   {
    initialValues.put(KEY_DAY, day[i]);
   }
 menuDb.insert(DATABASE_TABLE, null, initialValues);
 }

but that didn’t work. Then I tried this:

if(rowId == 0)
        {
            menuDbHelper.createMenu("Monday", "", "", "");
            menuDbHelper.createMenu("Tuesday", "", "", "");
            menuDbHelper.createMenu("Wednesday", "", "", "");
            menuDbHelper.createMenu("Thursday", "", "", "");
            menuDbHelper.createMenu("Friday", "", "", "");
            menuDbHelper.createMenu("Saturday", "", "", "");
            menuDbHelper.createMenu("Sunday", "", "", "");
            //menuDbHelper.installDays();
            rowId = 1;
        }

That works but its no good, if you hit the back button and come back to that activity it just adds them all over again and then I have fourteen days. What am I doing wrong here? I am new to Java so take it easy on 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-16T21:06:58+00:00Added an answer on May 16, 2026 at 9:06 pm

    You’re inserting records into your database every time you call that ListActivity. Do you have to use a database in this case? If you’re truly storing days of the week (assuming this isn’t an example), then you can simply store those values in an array that is initialized whenever that ListActivity is created. The docs state that the internal ListView in ListActivity can take an array as well as a cursor:

    ListActivity hosts a ListView object
    that can be bound to different data
    sources, typically either an array or
    a Cursor holding query results.
    ListActivity

    • 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.