How to play a video from resources

As am getting lots of good feedback on my answer on SO for the question How to play a video from the raw or assets folder, I thought of writing this small tutorial on playing a video in your activity.

String arrays and Object arrays in SharedPreferences

I see many questions on SO asking about the best mechanism to store some kind of preferences such as statistics, favorites, or shortcuts. Many of these questions are answered with "Use a database".

The biggest, yet clear, secret is that SharedPreferences are actually implemented using a

ListView with ability to hide rows

I do not know why! but someone on stackoverflow was asking about setting the height of a row of a ListView to zero.

Setting the height to zero will not work indeed! Many suggest to use View.Gone for the visibility of the row. However this is a ListView and therefore, setting a Visibility of Gone to one of the views will actually keep its space occupied while making its content vanish.

Anyway, here is an implementation of ArrayAdapter that has two public functions hide(int) and unHide(int) allowing the user to hide/unhide the row at the position.

Adding an Exit button to Android Application

So what is the right way of closing the application!

Usually it is "USER! press back ! press back! keep pressing back! we are close!! okay finally bye"


Here is a small idea i had on adding an Exit button to application.


In my personal opinion, even android users will find a Close button nice and friendly.

Passing primitive Data types between activities

After some time working on android projects, I discovered that it is actually very important to pass data between activities in most projects. It is rather simple when it comes to passing primitive datatypes.

Sax Class Generator -v1.0


Sax Class Generator is a class used to create a java class that extends org.xml.sax.helpers.DefaultHandler.

It creates everything based on the tree structure of the xml that you provide.

Current version depends on the GUI interface to get the nodes(structure) of the xml.



SoftKeyboard problem with Tabhost on bottom of screen

Many people (including myself) have encountered the problem of having an activity with a Tabhost aligned at the bottom of screen instead of its top.

What happens when you have an EditText or any other input method!
A soft keyboard will appear and push your TabHost above itself.

What's the solution for this? Turns out to be simple!