How to integrate fetched JSON data with Room Persistence libraryHow do I format a Microsoft JSON date?How can I pretty-print JSON in a shell script?How to reformat JSON in Notepad++?How to parse JSON in JavaWhy can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?How to parse JSON using Node.js?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I get ASP.NET Web API to return JSON instead of XML using Chrome?How do I write JSON data to a file?
Is it really a problem to declare that a visitor to the UK is my "girlfriend", in terms of her successfully getting a Standard Visitor visa?
Is the EU really banning "toxic propellants" in 2020? How is that going to work?
Please explain the difference in the order of naming Tzelafchad's daughters
Could flaps be raised upward to serve as spoilers / lift dumpers?
How to derive trigonometric Cartesian equation from parametric
A conjectural trigonometric identity
Base Current vs Emitter Base voltage
Can the additional attack from a Samurai's Rapid Strike have advantage?
IBM mainframe classic executable file formats
Is Norway in the Single Market?
Is there a general term for the items in a directory?
Conflict between senior and junior members
Being told my "network" isn't PCI Complaint. I don't even have a server! Do I have to comply?
Constant Scan spooling
Adjective for when skills are not improving and I'm depressed about it
Protect a 6 inch air hose from physical damage
Best Ergonomic Design for a handheld ranged weapon
UX writing: When to use "we"?
When did J.K. Rowling decide to make Ron and Hermione a couple?
A coworker mumbles to herself when working. How can I ask her to stop?
How do discovery writers hibernate?
How to compare files with diffrent extensions and delete extra files?
Can machine learning learn a function like finding maximum from a list?
Is this mechanically safe?
How to integrate fetched JSON data with Room Persistence library
How do I format a Microsoft JSON date?How can I pretty-print JSON in a shell script?How to reformat JSON in Notepad++?How to parse JSON in JavaWhy can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?How to parse JSON using Node.js?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I get ASP.NET Web API to return JSON instead of XML using Chrome?How do I write JSON data to a file?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am developing an Android Application (Android Studio - Java) which includes a sign in and registration process. I took care of the sign in and registration processes by implementing a connection between PHP files and a MySQL database through http. In short, I just created an AsyncTask class in java --called from another class-- and used it to post data to a PHP file, from there I just used the appropriate SQL commands. This part works fine.
This first part with the login and registration is important because every user will see a slightly different layout once they login. The layout is a RecyclerView composed of detailed CardView elements. Each CardView has a few TextViews with some details. The details are held by an Object i created in a separate class. To fill in the CardView elements a fetched some JSON data using a separate PHP file (and one more http connection). Parsing the data from JSON into Strings and ints was a straightforward endeavor, as was adding them to the list of custom objects. There is some code below showing how I fetched the data and added it to the Object list.
This is the complete AsyncTask class:
public class ScheduleWorker extends AsyncTask<String, Void, String>
Context context;
AlertDialog alertDialog;
ScheduleWorker (Context ctx) context = ctx;
@Override
protected void onPreExecute() super.onPreExecute();
@Override
protected void onPostExecute (String s)
super.onPostExecute(s);
Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
try
loadJSON(s);
catch (JSONException e)
e.printStackTrace();
@Override
protected String doInBackground(String... params)
final String fetch_url = "http://192.168.1.70/newfetcher.php";
try
String ussr_name = params[0];
URL url = new URL(fetch_url);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
OutputStream outputStream = con.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("user_name", "UTF-8")+"="+URLEncoder.encode(ussr_name, "UTF-8");
bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String json;
while ((json = bufferedReader.readLine()) != null)
sb.append(json + "n");
return sb.toString().trim();
catch (Exception e)
return null;
private void loadJSON(String json) throws JSONException
JSONArray jsonArray = new JSONArray(json);
Course course;
List<Course> courses = new ArrayList<Course>();
int len = jsonArray.length();
String[] titles = new String[len];
String[] types = new String[len];
String[] teachers = new String[len];
int[] pics = new int[len];
for (int i = 0; i < len; i++)
JSONObject obj = jsonArray.getJSONObject(i);
titles[i] = obj.getString("title");
types[i] = obj.getString("type");
teachers[i] = obj.getString("teacher");
pics[i] = obj.getInt("pic");
course = new Course(titles[i], types[i], teachers[i], pics[i]);
courses.add(course);
Now, where I encountered problems is when I tried saving the List of Objects (and their details) to a Room Persistent Database. I based my code for the Room Database off an example from Google Developer CodeLabs. I adapted the code for my particular needs but I kept the underlying class structure. The structure includes: an Entity, a DAO, a RoomDatabase, a Repository, a ViewModel, a ViewHolder, an Adapter for the RecyclerView, and a class to populate the database. Everything seems fine except for the part where I populate the database. The example populates the database by using a callback and an AsyncTask within the RoomDatabase class.
Here is populating AsyncTask:
private static RoomDatabase.Callback sRoomDatabaseCallback = new RoomDatabase.Callback()
@Override
public void onOpen(@NonNull SupportSQLiteDatabase db)
super.onOpen(db);
// If you want to keep the data through app restarts,
// comment out the following line.
new PopulateDbAsync(INSTANCE).execute();
;
/**
* Populate the database in the background.
* If you want to start with more words, just add them.
*/
private static class PopulateDbAsync extends AsyncTask<Void, Void, Void>
private final WordDao mDao;
PopulateDbAsync(WordRoomDatabase db)
mDao = db.wordDao();
@Override
protected Void doInBackground(final Void... params)
// Start the app with a clean database every time.
// Not needed if you only populate on creation.
Word word = new Word("Hello");
mDao.insert(word);
word = new Word("World");
mDao.insert(word);
return null;
My question is how do I populate the database with the detail arrays and/or the Object list? The example executes the callback every time a adding activity is called. I just want to populate the database when the user registers.
java php android json android-asynctask
add a comment |
I am developing an Android Application (Android Studio - Java) which includes a sign in and registration process. I took care of the sign in and registration processes by implementing a connection between PHP files and a MySQL database through http. In short, I just created an AsyncTask class in java --called from another class-- and used it to post data to a PHP file, from there I just used the appropriate SQL commands. This part works fine.
This first part with the login and registration is important because every user will see a slightly different layout once they login. The layout is a RecyclerView composed of detailed CardView elements. Each CardView has a few TextViews with some details. The details are held by an Object i created in a separate class. To fill in the CardView elements a fetched some JSON data using a separate PHP file (and one more http connection). Parsing the data from JSON into Strings and ints was a straightforward endeavor, as was adding them to the list of custom objects. There is some code below showing how I fetched the data and added it to the Object list.
This is the complete AsyncTask class:
public class ScheduleWorker extends AsyncTask<String, Void, String>
Context context;
AlertDialog alertDialog;
ScheduleWorker (Context ctx) context = ctx;
@Override
protected void onPreExecute() super.onPreExecute();
@Override
protected void onPostExecute (String s)
super.onPostExecute(s);
Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
try
loadJSON(s);
catch (JSONException e)
e.printStackTrace();
@Override
protected String doInBackground(String... params)
final String fetch_url = "http://192.168.1.70/newfetcher.php";
try
String ussr_name = params[0];
URL url = new URL(fetch_url);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
OutputStream outputStream = con.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("user_name", "UTF-8")+"="+URLEncoder.encode(ussr_name, "UTF-8");
bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String json;
while ((json = bufferedReader.readLine()) != null)
sb.append(json + "n");
return sb.toString().trim();
catch (Exception e)
return null;
private void loadJSON(String json) throws JSONException
JSONArray jsonArray = new JSONArray(json);
Course course;
List<Course> courses = new ArrayList<Course>();
int len = jsonArray.length();
String[] titles = new String[len];
String[] types = new String[len];
String[] teachers = new String[len];
int[] pics = new int[len];
for (int i = 0; i < len; i++)
JSONObject obj = jsonArray.getJSONObject(i);
titles[i] = obj.getString("title");
types[i] = obj.getString("type");
teachers[i] = obj.getString("teacher");
pics[i] = obj.getInt("pic");
course = new Course(titles[i], types[i], teachers[i], pics[i]);
courses.add(course);
Now, where I encountered problems is when I tried saving the List of Objects (and their details) to a Room Persistent Database. I based my code for the Room Database off an example from Google Developer CodeLabs. I adapted the code for my particular needs but I kept the underlying class structure. The structure includes: an Entity, a DAO, a RoomDatabase, a Repository, a ViewModel, a ViewHolder, an Adapter for the RecyclerView, and a class to populate the database. Everything seems fine except for the part where I populate the database. The example populates the database by using a callback and an AsyncTask within the RoomDatabase class.
Here is populating AsyncTask:
private static RoomDatabase.Callback sRoomDatabaseCallback = new RoomDatabase.Callback()
@Override
public void onOpen(@NonNull SupportSQLiteDatabase db)
super.onOpen(db);
// If you want to keep the data through app restarts,
// comment out the following line.
new PopulateDbAsync(INSTANCE).execute();
;
/**
* Populate the database in the background.
* If you want to start with more words, just add them.
*/
private static class PopulateDbAsync extends AsyncTask<Void, Void, Void>
private final WordDao mDao;
PopulateDbAsync(WordRoomDatabase db)
mDao = db.wordDao();
@Override
protected Void doInBackground(final Void... params)
// Start the app with a clean database every time.
// Not needed if you only populate on creation.
Word word = new Word("Hello");
mDao.insert(word);
word = new Word("World");
mDao.insert(word);
return null;
My question is how do I populate the database with the detail arrays and/or the Object list? The example executes the callback every time a adding activity is called. I just want to populate the database when the user registers.
java php android json android-asynctask
Are you trying to save coursesList<Course> courses
?
– nishon.tan
Mar 27 at 5:36
Yes, I want to save courses to a room persistent database, so that the user doesn't have to load all their data every time they log in. The Async Task for fetching the data is called in the onPostExecute method of the registration Async Task, so I just want to the save the data once when the user register
– InigoMontoyaJr
Mar 27 at 17:36
add a comment |
I am developing an Android Application (Android Studio - Java) which includes a sign in and registration process. I took care of the sign in and registration processes by implementing a connection between PHP files and a MySQL database through http. In short, I just created an AsyncTask class in java --called from another class-- and used it to post data to a PHP file, from there I just used the appropriate SQL commands. This part works fine.
This first part with the login and registration is important because every user will see a slightly different layout once they login. The layout is a RecyclerView composed of detailed CardView elements. Each CardView has a few TextViews with some details. The details are held by an Object i created in a separate class. To fill in the CardView elements a fetched some JSON data using a separate PHP file (and one more http connection). Parsing the data from JSON into Strings and ints was a straightforward endeavor, as was adding them to the list of custom objects. There is some code below showing how I fetched the data and added it to the Object list.
This is the complete AsyncTask class:
public class ScheduleWorker extends AsyncTask<String, Void, String>
Context context;
AlertDialog alertDialog;
ScheduleWorker (Context ctx) context = ctx;
@Override
protected void onPreExecute() super.onPreExecute();
@Override
protected void onPostExecute (String s)
super.onPostExecute(s);
Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
try
loadJSON(s);
catch (JSONException e)
e.printStackTrace();
@Override
protected String doInBackground(String... params)
final String fetch_url = "http://192.168.1.70/newfetcher.php";
try
String ussr_name = params[0];
URL url = new URL(fetch_url);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
OutputStream outputStream = con.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("user_name", "UTF-8")+"="+URLEncoder.encode(ussr_name, "UTF-8");
bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String json;
while ((json = bufferedReader.readLine()) != null)
sb.append(json + "n");
return sb.toString().trim();
catch (Exception e)
return null;
private void loadJSON(String json) throws JSONException
JSONArray jsonArray = new JSONArray(json);
Course course;
List<Course> courses = new ArrayList<Course>();
int len = jsonArray.length();
String[] titles = new String[len];
String[] types = new String[len];
String[] teachers = new String[len];
int[] pics = new int[len];
for (int i = 0; i < len; i++)
JSONObject obj = jsonArray.getJSONObject(i);
titles[i] = obj.getString("title");
types[i] = obj.getString("type");
teachers[i] = obj.getString("teacher");
pics[i] = obj.getInt("pic");
course = new Course(titles[i], types[i], teachers[i], pics[i]);
courses.add(course);
Now, where I encountered problems is when I tried saving the List of Objects (and their details) to a Room Persistent Database. I based my code for the Room Database off an example from Google Developer CodeLabs. I adapted the code for my particular needs but I kept the underlying class structure. The structure includes: an Entity, a DAO, a RoomDatabase, a Repository, a ViewModel, a ViewHolder, an Adapter for the RecyclerView, and a class to populate the database. Everything seems fine except for the part where I populate the database. The example populates the database by using a callback and an AsyncTask within the RoomDatabase class.
Here is populating AsyncTask:
private static RoomDatabase.Callback sRoomDatabaseCallback = new RoomDatabase.Callback()
@Override
public void onOpen(@NonNull SupportSQLiteDatabase db)
super.onOpen(db);
// If you want to keep the data through app restarts,
// comment out the following line.
new PopulateDbAsync(INSTANCE).execute();
;
/**
* Populate the database in the background.
* If you want to start with more words, just add them.
*/
private static class PopulateDbAsync extends AsyncTask<Void, Void, Void>
private final WordDao mDao;
PopulateDbAsync(WordRoomDatabase db)
mDao = db.wordDao();
@Override
protected Void doInBackground(final Void... params)
// Start the app with a clean database every time.
// Not needed if you only populate on creation.
Word word = new Word("Hello");
mDao.insert(word);
word = new Word("World");
mDao.insert(word);
return null;
My question is how do I populate the database with the detail arrays and/or the Object list? The example executes the callback every time a adding activity is called. I just want to populate the database when the user registers.
java php android json android-asynctask
I am developing an Android Application (Android Studio - Java) which includes a sign in and registration process. I took care of the sign in and registration processes by implementing a connection between PHP files and a MySQL database through http. In short, I just created an AsyncTask class in java --called from another class-- and used it to post data to a PHP file, from there I just used the appropriate SQL commands. This part works fine.
This first part with the login and registration is important because every user will see a slightly different layout once they login. The layout is a RecyclerView composed of detailed CardView elements. Each CardView has a few TextViews with some details. The details are held by an Object i created in a separate class. To fill in the CardView elements a fetched some JSON data using a separate PHP file (and one more http connection). Parsing the data from JSON into Strings and ints was a straightforward endeavor, as was adding them to the list of custom objects. There is some code below showing how I fetched the data and added it to the Object list.
This is the complete AsyncTask class:
public class ScheduleWorker extends AsyncTask<String, Void, String>
Context context;
AlertDialog alertDialog;
ScheduleWorker (Context ctx) context = ctx;
@Override
protected void onPreExecute() super.onPreExecute();
@Override
protected void onPostExecute (String s)
super.onPostExecute(s);
Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
try
loadJSON(s);
catch (JSONException e)
e.printStackTrace();
@Override
protected String doInBackground(String... params)
final String fetch_url = "http://192.168.1.70/newfetcher.php";
try
String ussr_name = params[0];
URL url = new URL(fetch_url);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
OutputStream outputStream = con.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("user_name", "UTF-8")+"="+URLEncoder.encode(ussr_name, "UTF-8");
bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String json;
while ((json = bufferedReader.readLine()) != null)
sb.append(json + "n");
return sb.toString().trim();
catch (Exception e)
return null;
private void loadJSON(String json) throws JSONException
JSONArray jsonArray = new JSONArray(json);
Course course;
List<Course> courses = new ArrayList<Course>();
int len = jsonArray.length();
String[] titles = new String[len];
String[] types = new String[len];
String[] teachers = new String[len];
int[] pics = new int[len];
for (int i = 0; i < len; i++)
JSONObject obj = jsonArray.getJSONObject(i);
titles[i] = obj.getString("title");
types[i] = obj.getString("type");
teachers[i] = obj.getString("teacher");
pics[i] = obj.getInt("pic");
course = new Course(titles[i], types[i], teachers[i], pics[i]);
courses.add(course);
Now, where I encountered problems is when I tried saving the List of Objects (and their details) to a Room Persistent Database. I based my code for the Room Database off an example from Google Developer CodeLabs. I adapted the code for my particular needs but I kept the underlying class structure. The structure includes: an Entity, a DAO, a RoomDatabase, a Repository, a ViewModel, a ViewHolder, an Adapter for the RecyclerView, and a class to populate the database. Everything seems fine except for the part where I populate the database. The example populates the database by using a callback and an AsyncTask within the RoomDatabase class.
Here is populating AsyncTask:
private static RoomDatabase.Callback sRoomDatabaseCallback = new RoomDatabase.Callback()
@Override
public void onOpen(@NonNull SupportSQLiteDatabase db)
super.onOpen(db);
// If you want to keep the data through app restarts,
// comment out the following line.
new PopulateDbAsync(INSTANCE).execute();
;
/**
* Populate the database in the background.
* If you want to start with more words, just add them.
*/
private static class PopulateDbAsync extends AsyncTask<Void, Void, Void>
private final WordDao mDao;
PopulateDbAsync(WordRoomDatabase db)
mDao = db.wordDao();
@Override
protected Void doInBackground(final Void... params)
// Start the app with a clean database every time.
// Not needed if you only populate on creation.
Word word = new Word("Hello");
mDao.insert(word);
word = new Word("World");
mDao.insert(word);
return null;
My question is how do I populate the database with the detail arrays and/or the Object list? The example executes the callback every time a adding activity is called. I just want to populate the database when the user registers.
java php android json android-asynctask
java php android json android-asynctask
asked Mar 26 at 23:43
InigoMontoyaJrInigoMontoyaJr
227 bronze badges
227 bronze badges
Are you trying to save coursesList<Course> courses
?
– nishon.tan
Mar 27 at 5:36
Yes, I want to save courses to a room persistent database, so that the user doesn't have to load all their data every time they log in. The Async Task for fetching the data is called in the onPostExecute method of the registration Async Task, so I just want to the save the data once when the user register
– InigoMontoyaJr
Mar 27 at 17:36
add a comment |
Are you trying to save coursesList<Course> courses
?
– nishon.tan
Mar 27 at 5:36
Yes, I want to save courses to a room persistent database, so that the user doesn't have to load all their data every time they log in. The Async Task for fetching the data is called in the onPostExecute method of the registration Async Task, so I just want to the save the data once when the user register
– InigoMontoyaJr
Mar 27 at 17:36
Are you trying to save courses
List<Course> courses
?– nishon.tan
Mar 27 at 5:36
Are you trying to save courses
List<Course> courses
?– nishon.tan
Mar 27 at 5:36
Yes, I want to save courses to a room persistent database, so that the user doesn't have to load all their data every time they log in. The Async Task for fetching the data is called in the onPostExecute method of the registration Async Task, so I just want to the save the data once when the user register
– InigoMontoyaJr
Mar 27 at 17:36
Yes, I want to save courses to a room persistent database, so that the user doesn't have to load all their data every time they log in. The Async Task for fetching the data is called in the onPostExecute method of the registration Async Task, so I just want to the save the data once when the user register
– InigoMontoyaJr
Mar 27 at 17:36
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367744%2fhow-to-integrate-fetched-json-data-with-room-persistence-library%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367744%2fhow-to-integrate-fetched-json-data-with-room-persistence-library%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you trying to save courses
List<Course> courses
?– nishon.tan
Mar 27 at 5:36
Yes, I want to save courses to a room persistent database, so that the user doesn't have to load all their data every time they log in. The Async Task for fetching the data is called in the onPostExecute method of the registration Async Task, so I just want to the save the data once when the user register
– InigoMontoyaJr
Mar 27 at 17:36