How to add common utility for Android application in Android Studio


Hi Friends,Today I am going to share one utility class which I have created and using in my projects to simplify my common utility requirements.

I have created one Util class and created my methods as static which helps in accessing these methods without class objects.

Just call MyUtils.methodname(context) to access the method from any where from your app. Short Description: Call MyUtils.readJsonForMe(context) to access these methods.

I have created the test_json file inside raw directory with following content: To create raw directory:Right click on raw–>choose create resource directory and name it as raw and place your test.json file inside it.

Top 10 free Android libraries for app development in android studio

{“employees”:[ {“firstName”:”John”, “lastName”:”Doe”}, {“firstName”:”Anna”, “lastName”:”Smith”}, {“firstName”:”Peter”, “lastName”:”Jones”} ]}

 

Ravi Yadav is an Android developer whose passion is to develop Android applications and sharing his work. He loves to post  the tutorials which he created while learning any new latest technology topic.He loves to share about the latest technology happenings and other tricks that will be helpful for readers of Askfortricks.