I have a date/time that I get from a sqlite database and want to show in my Android app. I want it in the format :
9 November, 12:12. How do I do this? Is it best to format it before or after I enter it into the database?
See the answers to this question.
In your database, I would suggest you keep timestamps in there rather than the formatted strings. That way your program would still work if you decide to change the format later.
Related
I have the following question: I should create a chart in app activity. The first axis of this chart is temperature and the second is date when such temperature was. I am thinking of using SQLite for keeping this data, because I think that this data is easier to process. Or there is no need in it and it's better to use usual file. But how can I process the date if it keeps in format dd.mm.yyyy in such case?
Using Sqlite is fine.
Then use epoch for date/time. I.e seconds or mSec since 1.1.1970.
Visit https://github.com/PhilJay/MPAndroidChart that may help you in your app.
Sqlite would be a good to store all your data.
this is my first app and I am trying to help out a business that I work for. Basically I picked up Android Tablet Application for Dummies and have been using it as reference. I am making a sort of time card application for a business I work for. My goal is that I want to take the information that the workers would enter in over the course of the day, and have them email it to the person writing payroll. Is there any way for me to just email the database with all of the contents? Or a simple way to send the contents in another easy to read format? Open to all suggestions and alternatives, thank you for your time!
A raw db file probably is not going to be terribly useful for the payroll person.
If I were you I'd make something that will query your DB for all rows, once you have the resulting cursor you can iterate over it and put the data into some more useful data format.
The data format you choose depends on your situation. XML or CSV seem like good options. CSV perhaps a little bit better since it would be able to be opened in Excel (which anyone in payroll probably has access to)
You could also make your own data format if you want. Some sort of plain txt flatfile would be easiest, and it would be very human readable (Easier for payroll employee)
something like this:
IN Mike 2:31pm 6/14
IN Joe 2:45pm 6/14
OUT Mike 4:55pm 6/14
etc...
Then if you were nice you'd make something to go at the end that will tally up total hours for the day and/or pay period
Total Hours for period
Mike: 25.4
Joe: 22.3
etc...
EDIT: There are many examples of CSV all around the web.
Start Here to learn what it is.
Once you understand what it is you'll need to learn how to implement the read/write in java. You can do it with plain java using strings fairly easy. But there are also some Libraries out that that make it a whole lot easier for you to interact with CSV data.
The question is when I get the country sim code from android device I want to get the country number from a database or from a text file. Unfortunately as I know (so sadly) We cannot get a country code from the api as number like 44 31 33 whatever the country.In this case I want to use a table and match the country code with the number and use the number. for example, if the getSimCountryCode() returns gb one method will go and check the database and find +44 country code. So what do you think the best way and lightweight way of doing this? Do you think I should use sqlite and put the one to one data there and retrieve the data from database or is there a better way of dong it as a separate string file.
Thanks
I think the answer depends on how large your country code table will be. If it is small, then loading it into something like an in-memory Map might be fine. Otherwise, SQLite will be the way to go if it is a very large dataset.
I am working on an Android app that I would like to code in such a way so that the Spanish characters coming from the database are read as equivalent to the English ones. For instance, cafe and café would be identical.
Is there a way to do this?
Do you mean that you want queries to find both "cafe" and "café" when you search for "cafe"? You should be able to use a regular expressions to do this.
If this needs to be done on the fly, you could write a function that parses the request for 'e' and generate the correct regular expression before creating the DB query.
Hello this is probably a typical question but i cant seem to find a clear answer?
I have a backend application that will serve data in json form.
The data will be in form [code] [name].
The data sets might vary from 100-2000 rows.
What would be best...
Store directly these json responses as files and then parse them if they exist?
Or store them in the android database?
In each case the data does not change that often maybe 1 per week.
Which way would be the faster and which more efficient?
Thanks
I think database is much more preferable way here. Text rows even in quantities like 2000 on smart phones better not to be handled in text I think.
I'd go for the Sqlite db too, I'm quite sure that it's much faster than using basic file i/o.