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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:39:17+00:00 2026-05-21T09:39:17+00:00

I am writing an Android app that allows the user to add a new

  • 0

I am writing an Android app that allows the user to add a new Module to the database and add the day, starttime, finish time and room for that module.

The user is able to view all classes for a particular day.

The problem i am having is, right now i am currently taking the start time and finish time as text because i couldnt find out how to take it in as a time.

1) The user clicks the EditText, a TimePicker Dialog pops up, the user selects the hour and minute and the EditText text is set to the time picked.

2) The text in the EditText is then taken and saved into the database.

I have everything working fine, the only problem i am facing is that when the user is viewing all the classes for a particular day i want it to be ordered by start time i.e. the first class, the second and so on. But right now its only showing it in the order it was inserted into the database. I have tried the ORDER BY and it just wouldnt work.

I am guessing i would have to change the data type of the start time and finish time.

db.execSQL("CREATE TABLE AllModulesInfo (_id INTEGER PRIMARY KEY AUTOINCREMENT, moduleName TEXT, day Text, startTime Text, finishTime Text, room Text);");

    public void insertIntoAllMod(String moduleName, String day, String startTime, String finishTime, String room)
    {
        ContentValues daysInfo = new ContentValues();
        daysInfo.put("moduleName", moduleName);
        daysInfo.put(Day, day);
        daysInfo.put(StartTime, startTime);
        daysInfo.put(FinishTime, finishTime);
        daysInfo.put(Room, room);           
        db.insert("AllModulesInfo", null, daysInfo);
    }

Thanks in advance, if there is anything i havent explained properly or any information i have left out that will assist you in assiting me to fix this problem, PLEASE let me know. 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-05-21T09:39:17+00:00Added an answer on May 21, 2026 at 9:39 am

    It looks like you’re using strings for your timestamps. You need to use an integer to actually store a unix timestamp. Then your queries will using ORDER BY will sort correctly, ex:

    SELECT * FROM table WHERE .... ORDER BY updateTime
    

    I’d suggest converting the string to an integer using straight Java, since that allows you to use those parameterized inserts like you showed in your example. However, you could manually write the queries and use the time functions provided by SQLite:

    http://www.sqlite.org/lang_datefunc.html


    Edit:

    It appears you can use a string timestamp with SQLite, but only a few formats are supported (that page has examples.) I’m not sure that works in Android though, I’ve always used integer field types for times (which can actually store Java longs.)

    — Dan

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

Sidebar

Related Questions

I am looking into writing an Android app that has a database of approximately
I am writing a simple Android app and have a database that will send
I'm writing an Android application that allows a user to maintain a list of
I'm learning Java and writing an android app that consumes a JSON object that
I'm writing an Android app for work that shows the status of our phone
I've been writing an Android app that is mainly driven by hardware keyboard input.
I writing a report in Visual Studio that takes a user input parameter and
I'm writing an Android App and I'm looking for the fastest (In terms of
I am writing a screen scraping app that reads out various pages and extracts
I'm writing an Android application that I want to be able to send requests

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.