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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:48:23+00:00 2026-06-07T21:48:23+00:00

I want to store the current data/time and the Button Id into some file.

  • 0
  1. I want to store the current data/time and the Button Id into some file.
  2. Currently, I am doing this with Internal Storage, but this is not working for me.
  3. I am able to store the String (as most of us can find in various tutorials) but I am not able to store the Date/time and button id. For String, we can easily use fos.write(string.getbyte[]).
  4. Another thing that I want to do is after storing the data into the file, I want to access that file so that I can manipulate data from it.

Eg. There are few buttons, TV_ON, TV_OFF, DVD_ON, etc. If I will click TV_ON button, it will store the Button Id and at what time that button is pressed. And if TV_OFF is pressed, it will store the corresponding Id and Time. So that I can get the duration for which TV was ON. This way I will able to interpret Energy Consumed during that duration (Using some calculations).

Please Guide !!

  • 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-07T21:48:25+00:00Added an answer on June 7, 2026 at 9:48 pm

    You need to convert a Date to String using a formatter because same date could be represented in many different ways. Printing button id is straightforward:

    Date date = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String logMsg = "Date: " + formatter.format(date) + " Button id: " + R.id.your_button_id;
    Log.i(tag, logMsg);
    fos.write(logMsg);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to store a .NET object into Azure Blob Storage. Currently I serialize
I want to store the current date & time which can be get by
I want to store the data and time in my MYSQL db.I have a
I'm trying to save the parsed data into MongoDB. I want to store every
I want to store data in MySQL and query it based on the current
I am a new developer on Android and I want store user data in
I want to store user-clicked data in a cookie which never has to go
Some co-workers and I got into a debate on the best way to store
I am using ZODB to store some data that exists in memory for the
I have some stock market data. I want to simulate the stock market by

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.