Void's Vault

Knowledge source for efficiency.

A Gas App for Android - SQLite

I bought an android smartphone last summer. Shame on my geek attitude, I decided to do that only because I wanted to learn how to program for android phones. In fact, it’s quite simple and, fortunately for me, it was documented a lot by the google team. Since I just finished my bachelor in software engineering, I also bought a car. So I told myself: “Hey, why don’t you do a simple app so you can learn AND follow your gas consumption at the same time?”.

Well… That’s what I did.

I made an app that allows me to see my gas consumption and various statistics in cute little graphs. I can also follow what I spend on my car so I know when I will need to bring it to a garage for a review and so on…

Write me if you ever want the code. I have not brought the app to the google store yet. I will not put the code here since it would be a bit tedious, but here’s some details about the implementation. I have a main menu activity presenting choices of possible actions. You can add a new gas entry, see the statistics of gas consumption, add a new money spending entry or see the statistics of the maintenance of the vehicule.

In the image, the left part is the activity of adding an entry and the right part is the statistics of gas consumption. Just by sliding with your thumb while in the gas statistics activity, you can view the multiple graphs.

The app’s data is saved via an SQLite database. Here’s an interesting link on how to use SQLite with android.

To set dates, I used DatePickers. The best tutorial I found about the way to use them is there.

The graphs I created were developped using this post on StackOverflow

This guy also showed me a clean way to use Spinners (selectable drop-down list).

For the linking between activities and FragmentDialogs or sub activities, I found everything on google’s documentation of android.

Don’t hesitate to ask me if you want to try it, it will be a pleasure to give my app to you as long as the stays OpenSource.