본문 바로가기

카테고리 없음

Storing Data in Android: Intro

A key takeaway from life cycles is that your application runs until Android needs to free resources or something else.


That means, it's best if we design Sunshine to contitnue to work well even if the operating system has to close us and the app no longer has weather data.


One might ask, this is the error of the connected cloud.


Why don't we just always fetch the weather on demand?


Do we really need to worry about saving anything on the device?


Well, first, user experience is important.


When Sunshine is launched, we want our users to be immediately greeted with up to date hot off the API weather information and not a blank screen.


The faster people can use an app, the more it will be used.


For something like weather, people want the details immediately available.


Second, using any radio is detrimental to the battery life of the device, especially the cellular radio.


Storing the weather data rather than fetching it each time saves battery life.


And that leads to happier users.


Third, there are many users on metered data plans or users may be roaming when they want to use Sunshine.


All those unnecessary data fetches can add up.


Fourth, if you're running a web service for your application, you'll be highly motivated to reduce the server load and network bandwidth.


Fifth, there are still lots of places that don't have a network connection available constantly.


One of the prime advantages of having a mobile app is being resistant to bad or non-existent network conditions.


Sixth, and finally, you never know where a user will want to use your app.


Although our weather API currently doesn't support outer space locations.


Being smart about the way we use system resources is key to making the Sunshine a good Android citizen.


As conscientious developers, we strive to make all of our apps adhere to these principles by minimizing network activity and working seamlessly between offline and onlie states.


We persist data in Sunshine to make it both a better experience for users, while making it use less network and battery resources.