- I want to store the current data/time and the Button Id into some file.
- Currently, I am doing this with Internal Storage, but this is not working for me.
- 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[]).
- 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 !!
You need to convert a
DatetoStringusing aformatterbecause same date could be represented in many different ways. Printing button id is straightforward: