Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send fetched data in Splash Screen Activity to other activity in Kotlin?

Tags:

android

kotlin

Fetched data is a JSON string list of Users. Let's say it has 5 string-value property and it would be less than 30 user. I thought that i could just put it in Intent, but:

  1. Is it really the best way to do it?
  2. What if there is hundreds of user, what is the best way?

FYI i'm using Fuel to fetch data and it could request asynchronously.

like image 707
rifqimf127 Avatar asked Nov 20 '25 15:11

rifqimf127


1 Answers

As per your question, you are fetching the data on the Splash Screen (Activity). Also, you confirm that the data can be fetched asynchronously.

I would suggest, that instead of fetching the data on Splash Screen, fetch the data directly in the activity where the data is required.

However, there could be several ways of storing the data instead of using Intent to pass data between activities. Some of the ways are as below:

  1. Database (Room) - These are used to store data and query accordingly. You can save data in multiple tables too based on your requirements.
  2. SharedPreferences - Best used to store frequently accessed data. This too can be used to save JSON Response.
  3. File Storage - You can also save the data to a file for access.

You can read about storing data in Android in detail to better select a way to save and pass data.

like image 115
Atish Agrawal Avatar answered Nov 23 '25 07:11

Atish Agrawal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!