Boost Up Your Android Apps Performance

11 steps to make your app perform well with low-end devices.

MohammedSaif Kordia
CodeX
4 min readAug 17, 2021

--

Photo by Jonny Lew from Pexels

What I love about Android devices that it’s affordable for everyone.
As an Android developer, when you start your Android project, you must take into consideration all of the hardware types.

We have a good variety of hardware, starting from the lowest MediaTek to the highest SnapDragon, and from the half gig of ram to 12+ gig of ram at the time of writing this article.

Let’s say that you are a successful Android developer and can afford a very high-end device, it helps you in your job and the life is good, but…
Think about your users, can they all afford the same type of your device? the answer is no.

I can hear someone say “I’ve been in the field for many years and no one complained about the performance, why should I bother?”

Why should I bother?

  • To show respect:
    All of your users deserve to have the same remarkable user experience.
  • Business opportunities:
    Are you ready to risk losing a big slice of the market? large companies, big restaurants, multi-location groceries, and more, tend to get a low-end devices to cut the expenses, you better think of these opportunities to take advantage over other apps and developers.

Before we go:

We talked before about the clean architecture and MVI, and how to set up your project to use them, I’m not gonna reinvent the wheel, so I’ll start from where we stopped.
You can check the previous article here:

The mentioned article is meant to make your life easier, but what about the user’s life!

What steps can I take to make my app perform better?

1- Think smarter

Think in a smart way to reduce the number of processes to do the same job.

  • If your app has a server on its back, try to put the heavy load on the server, don’t process all your data and reports locally.
  • If you are getting the data from a local database, optimize your queries by using out-of-the-box database operations to get the data ready to use.

2- Use threading

  • Make use of the threading and parallel jobs like ReactivX(RxJava) and Coroutines.
  • In ReactivX you can easily subscribe on one thread and observe on another, don’t forget to dispose all of your subscribers in onDestroy/onCleared.
    Coroutines also have some cool stuff to use threading professionally, you can start the process in the IO thread and finish it in the Main thread.

3- Sub-model your data

When requesting the data from API or database, ask only for what you need, don’t be afraid to make and use sub-models.
By this I mean if you have a table with 50 fields, and all you need to show is a few fields like 4–5, why to overload the streams and fill the ram, just make a sub-model of the main model and get that data out-of-the-box, the same goes for the database, just SELECT what you need.

4- Don’t leave any open connections

It’s a bad idea to do so, it may cause exceptions and overflow the ram, you can even get a deadlock and freeze your app, close any open connections once you are done with it.

5- Simplify your UIs

At the UI level(XML) try to simplify the UI, the deeper you go the slowest you get.
Help your app to render faster by reducing the depth of your UI, constraint layout is amazing in this, guidelines can help you a lot.

6- Bind your views and data

Use data binding and view binding, this will help you directly inject the data to the UI, no need for all that findViewById thing, get rid of it.

7- Paging

Make use of paging in your adapters, it’s a very bad practice to request all of the data at once, what if you have 100k rows in the database, can a low-end device handle it? not even a high-end one.

8- Optimize database queries

Profile and debug your database queries, this could make a big difference.
If your query is a bit complex, you might want to take a second look at it, help the database to get your data faster.

9- Use native libraries

Stay away from the third-party libraries as you can, some libraries are poor in implementation, even if it gives you what you looking for, it might be the bottle nick in your app.

10- Drawables and layouts

Divide your drawables and layouts by the screen size, don’t worry about the app size, the aab will handle it.
Android is smart enough to choose the drawable/layout that fits well with the screen size, 5" low-end device is not the same as a 65" screen.

11- Be realistic

Test your app on a real low-end device, or use a customizable Android emulator, the built-in Android emulator is too good to be used.

Conclusion…

Every single user matters and counts, no matter what type of app you are developing, performance can take your app from zero to hero in no time, don't leave money on the table, and optimize your app to fit with all types of hardware.

References…

https://developer.android.com/topic/libraries/architecture/paging/v3-overview

https://developer.android.com/topic/libraries/data-binding

https://developer.android.com/training/multiscreen/screendensities

--

--