onsavedinstancestate doesn't appear to support double array list what are my options?












0














OnSavedInstanceState in android doesn't appear to save double array list. I'm thinking the best way thing to do here is to convert the double array list to a double array, How do I go about doing that?



Is there a better option than convert double array list to double array.



/* Storage for parsed JSON data */
private List<String> mPosterPaths = new ArrayList<>();
private List<String> mTitleList = new ArrayList<>();
private List<String> mDescriptionList = new ArrayList<>();
private List<Double> mRatingList = new ArrayList<>();
private List<String> mDateList = new ArrayList<>();
private List<Integer> mIdList = new ArrayList<>();


@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Double rating = mRatingList.toArray(new Double[0]);
outState.putString("SavedState", mSortType);
outState.putStringArrayList("PosterPath", (ArrayList<String>) mPosterPaths);
outState.putStringArrayList("MovieTitle", (ArrayList<String>) mTitleList);
outState.putIntegerArrayList("MovieID", (ArrayList<Integer>) mIdList);
outState.putStringArrayList("Plot", (ArrayList<String>) mDescriptionList);
outState.putDoubleArray("Rating", mRatingList);
outState.putStringArrayList("Release Date", (ArrayList<String>) mDateList);



}









share|improve this question
























  • Please post the code, and also please note that when you store data in bundle it should be parcelable or serilizable
    – Rohit
    Nov 13 '18 at 3:22










  • I've include the my code hopefully that helps
    – morefaster
    Nov 13 '18 at 3:28
















0














OnSavedInstanceState in android doesn't appear to save double array list. I'm thinking the best way thing to do here is to convert the double array list to a double array, How do I go about doing that?



Is there a better option than convert double array list to double array.



/* Storage for parsed JSON data */
private List<String> mPosterPaths = new ArrayList<>();
private List<String> mTitleList = new ArrayList<>();
private List<String> mDescriptionList = new ArrayList<>();
private List<Double> mRatingList = new ArrayList<>();
private List<String> mDateList = new ArrayList<>();
private List<Integer> mIdList = new ArrayList<>();


@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Double rating = mRatingList.toArray(new Double[0]);
outState.putString("SavedState", mSortType);
outState.putStringArrayList("PosterPath", (ArrayList<String>) mPosterPaths);
outState.putStringArrayList("MovieTitle", (ArrayList<String>) mTitleList);
outState.putIntegerArrayList("MovieID", (ArrayList<Integer>) mIdList);
outState.putStringArrayList("Plot", (ArrayList<String>) mDescriptionList);
outState.putDoubleArray("Rating", mRatingList);
outState.putStringArrayList("Release Date", (ArrayList<String>) mDateList);



}









share|improve this question
























  • Please post the code, and also please note that when you store data in bundle it should be parcelable or serilizable
    – Rohit
    Nov 13 '18 at 3:22










  • I've include the my code hopefully that helps
    – morefaster
    Nov 13 '18 at 3:28














0












0








0







OnSavedInstanceState in android doesn't appear to save double array list. I'm thinking the best way thing to do here is to convert the double array list to a double array, How do I go about doing that?



Is there a better option than convert double array list to double array.



/* Storage for parsed JSON data */
private List<String> mPosterPaths = new ArrayList<>();
private List<String> mTitleList = new ArrayList<>();
private List<String> mDescriptionList = new ArrayList<>();
private List<Double> mRatingList = new ArrayList<>();
private List<String> mDateList = new ArrayList<>();
private List<Integer> mIdList = new ArrayList<>();


@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Double rating = mRatingList.toArray(new Double[0]);
outState.putString("SavedState", mSortType);
outState.putStringArrayList("PosterPath", (ArrayList<String>) mPosterPaths);
outState.putStringArrayList("MovieTitle", (ArrayList<String>) mTitleList);
outState.putIntegerArrayList("MovieID", (ArrayList<Integer>) mIdList);
outState.putStringArrayList("Plot", (ArrayList<String>) mDescriptionList);
outState.putDoubleArray("Rating", mRatingList);
outState.putStringArrayList("Release Date", (ArrayList<String>) mDateList);



}









share|improve this question















OnSavedInstanceState in android doesn't appear to save double array list. I'm thinking the best way thing to do here is to convert the double array list to a double array, How do I go about doing that?



Is there a better option than convert double array list to double array.



/* Storage for parsed JSON data */
private List<String> mPosterPaths = new ArrayList<>();
private List<String> mTitleList = new ArrayList<>();
private List<String> mDescriptionList = new ArrayList<>();
private List<Double> mRatingList = new ArrayList<>();
private List<String> mDateList = new ArrayList<>();
private List<Integer> mIdList = new ArrayList<>();


@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Double rating = mRatingList.toArray(new Double[0]);
outState.putString("SavedState", mSortType);
outState.putStringArrayList("PosterPath", (ArrayList<String>) mPosterPaths);
outState.putStringArrayList("MovieTitle", (ArrayList<String>) mTitleList);
outState.putIntegerArrayList("MovieID", (ArrayList<Integer>) mIdList);
outState.putStringArrayList("Plot", (ArrayList<String>) mDescriptionList);
outState.putDoubleArray("Rating", mRatingList);
outState.putStringArrayList("Release Date", (ArrayList<String>) mDateList);



}






android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 3:27

























asked Nov 13 '18 at 3:14









morefaster

478




478












  • Please post the code, and also please note that when you store data in bundle it should be parcelable or serilizable
    – Rohit
    Nov 13 '18 at 3:22










  • I've include the my code hopefully that helps
    – morefaster
    Nov 13 '18 at 3:28


















  • Please post the code, and also please note that when you store data in bundle it should be parcelable or serilizable
    – Rohit
    Nov 13 '18 at 3:22










  • I've include the my code hopefully that helps
    – morefaster
    Nov 13 '18 at 3:28
















Please post the code, and also please note that when you store data in bundle it should be parcelable or serilizable
– Rohit
Nov 13 '18 at 3:22




Please post the code, and also please note that when you store data in bundle it should be parcelable or serilizable
– Rohit
Nov 13 '18 at 3:22












I've include the my code hopefully that helps
– morefaster
Nov 13 '18 at 3:28




I've include the my code hopefully that helps
– morefaster
Nov 13 '18 at 3:28












1 Answer
1






active

oldest

votes


















1














You could try to convert your ratings List to an Array:



double ratings = new double[mRatingList.size()];
for (int i = 0; i < mRatingList.size(); i++) {
ratings[i] = mRatingList.get(i);
}
savedInstanceState.putDoubleArray("Rating", ratings);


And when it is being restored:



@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
double ratings = savedInstanceState.getDoubleArray("Rating");
List<Double> ratingList = new ArrayList<>();
for (double rating : ratings) {
ratingList.add(rating);
}
// ...
}





share|improve this answer























  • This didn't work for me unless I'm missing something. This is what the Log.d Prints back. D/doubleconvert: arrayList[6.6, 5.6, 8.3, 7.6, 6.0, 8.3, 7.5, 6.2, 5.3, 7.3, 6.9, 7.0, 6.6, 6.9, 5.5, 6.5, 6.4, 4.1, 6.1, 6.9] 2018-11-12 21:07:49.064 23845-23845/com.shawn.nichol.moviesstage2 D/doubleconvert: array[D@81ead05
    – morefaster
    Nov 13 '18 at 4:11










  • As you mentioned, Bundle doesn't support list of doubles. But it supports array of doubles, so you could try to convert the list to an array and put them in the Bundle, unless I misunderstood you?
    – Aaron
    Nov 13 '18 at 4:20










  • @morefaster By the way its double not Double if that's what you mean, otherwise other options will be converting those to Serializable or Parcelable, or even String.
    – Aaron
    Nov 13 '18 at 4:24










  • I just caught that two thinking that might the issue but I still get this response from the Log [D@a983e61.
    – morefaster
    Nov 13 '18 at 4:27






  • 1




    Were you trying to print by array.toString()? That'd only give you a hash value. If you want to print readable strings, then try Arrays.toString(array).
    – Aaron
    Nov 13 '18 at 4:36











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273256%2fonsavedinstancestate-doesnt-appear-to-support-double-array-list-what-are-my-opt%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You could try to convert your ratings List to an Array:



double ratings = new double[mRatingList.size()];
for (int i = 0; i < mRatingList.size(); i++) {
ratings[i] = mRatingList.get(i);
}
savedInstanceState.putDoubleArray("Rating", ratings);


And when it is being restored:



@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
double ratings = savedInstanceState.getDoubleArray("Rating");
List<Double> ratingList = new ArrayList<>();
for (double rating : ratings) {
ratingList.add(rating);
}
// ...
}





share|improve this answer























  • This didn't work for me unless I'm missing something. This is what the Log.d Prints back. D/doubleconvert: arrayList[6.6, 5.6, 8.3, 7.6, 6.0, 8.3, 7.5, 6.2, 5.3, 7.3, 6.9, 7.0, 6.6, 6.9, 5.5, 6.5, 6.4, 4.1, 6.1, 6.9] 2018-11-12 21:07:49.064 23845-23845/com.shawn.nichol.moviesstage2 D/doubleconvert: array[D@81ead05
    – morefaster
    Nov 13 '18 at 4:11










  • As you mentioned, Bundle doesn't support list of doubles. But it supports array of doubles, so you could try to convert the list to an array and put them in the Bundle, unless I misunderstood you?
    – Aaron
    Nov 13 '18 at 4:20










  • @morefaster By the way its double not Double if that's what you mean, otherwise other options will be converting those to Serializable or Parcelable, or even String.
    – Aaron
    Nov 13 '18 at 4:24










  • I just caught that two thinking that might the issue but I still get this response from the Log [D@a983e61.
    – morefaster
    Nov 13 '18 at 4:27






  • 1




    Were you trying to print by array.toString()? That'd only give you a hash value. If you want to print readable strings, then try Arrays.toString(array).
    – Aaron
    Nov 13 '18 at 4:36
















1














You could try to convert your ratings List to an Array:



double ratings = new double[mRatingList.size()];
for (int i = 0; i < mRatingList.size(); i++) {
ratings[i] = mRatingList.get(i);
}
savedInstanceState.putDoubleArray("Rating", ratings);


And when it is being restored:



@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
double ratings = savedInstanceState.getDoubleArray("Rating");
List<Double> ratingList = new ArrayList<>();
for (double rating : ratings) {
ratingList.add(rating);
}
// ...
}





share|improve this answer























  • This didn't work for me unless I'm missing something. This is what the Log.d Prints back. D/doubleconvert: arrayList[6.6, 5.6, 8.3, 7.6, 6.0, 8.3, 7.5, 6.2, 5.3, 7.3, 6.9, 7.0, 6.6, 6.9, 5.5, 6.5, 6.4, 4.1, 6.1, 6.9] 2018-11-12 21:07:49.064 23845-23845/com.shawn.nichol.moviesstage2 D/doubleconvert: array[D@81ead05
    – morefaster
    Nov 13 '18 at 4:11










  • As you mentioned, Bundle doesn't support list of doubles. But it supports array of doubles, so you could try to convert the list to an array and put them in the Bundle, unless I misunderstood you?
    – Aaron
    Nov 13 '18 at 4:20










  • @morefaster By the way its double not Double if that's what you mean, otherwise other options will be converting those to Serializable or Parcelable, or even String.
    – Aaron
    Nov 13 '18 at 4:24










  • I just caught that two thinking that might the issue but I still get this response from the Log [D@a983e61.
    – morefaster
    Nov 13 '18 at 4:27






  • 1




    Were you trying to print by array.toString()? That'd only give you a hash value. If you want to print readable strings, then try Arrays.toString(array).
    – Aaron
    Nov 13 '18 at 4:36














1












1








1






You could try to convert your ratings List to an Array:



double ratings = new double[mRatingList.size()];
for (int i = 0; i < mRatingList.size(); i++) {
ratings[i] = mRatingList.get(i);
}
savedInstanceState.putDoubleArray("Rating", ratings);


And when it is being restored:



@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
double ratings = savedInstanceState.getDoubleArray("Rating");
List<Double> ratingList = new ArrayList<>();
for (double rating : ratings) {
ratingList.add(rating);
}
// ...
}





share|improve this answer














You could try to convert your ratings List to an Array:



double ratings = new double[mRatingList.size()];
for (int i = 0; i < mRatingList.size(); i++) {
ratings[i] = mRatingList.get(i);
}
savedInstanceState.putDoubleArray("Rating", ratings);


And when it is being restored:



@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
double ratings = savedInstanceState.getDoubleArray("Rating");
List<Double> ratingList = new ArrayList<>();
for (double rating : ratings) {
ratingList.add(rating);
}
// ...
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 5:09

























answered Nov 13 '18 at 3:51









Aaron

1,6831212




1,6831212












  • This didn't work for me unless I'm missing something. This is what the Log.d Prints back. D/doubleconvert: arrayList[6.6, 5.6, 8.3, 7.6, 6.0, 8.3, 7.5, 6.2, 5.3, 7.3, 6.9, 7.0, 6.6, 6.9, 5.5, 6.5, 6.4, 4.1, 6.1, 6.9] 2018-11-12 21:07:49.064 23845-23845/com.shawn.nichol.moviesstage2 D/doubleconvert: array[D@81ead05
    – morefaster
    Nov 13 '18 at 4:11










  • As you mentioned, Bundle doesn't support list of doubles. But it supports array of doubles, so you could try to convert the list to an array and put them in the Bundle, unless I misunderstood you?
    – Aaron
    Nov 13 '18 at 4:20










  • @morefaster By the way its double not Double if that's what you mean, otherwise other options will be converting those to Serializable or Parcelable, or even String.
    – Aaron
    Nov 13 '18 at 4:24










  • I just caught that two thinking that might the issue but I still get this response from the Log [D@a983e61.
    – morefaster
    Nov 13 '18 at 4:27






  • 1




    Were you trying to print by array.toString()? That'd only give you a hash value. If you want to print readable strings, then try Arrays.toString(array).
    – Aaron
    Nov 13 '18 at 4:36


















  • This didn't work for me unless I'm missing something. This is what the Log.d Prints back. D/doubleconvert: arrayList[6.6, 5.6, 8.3, 7.6, 6.0, 8.3, 7.5, 6.2, 5.3, 7.3, 6.9, 7.0, 6.6, 6.9, 5.5, 6.5, 6.4, 4.1, 6.1, 6.9] 2018-11-12 21:07:49.064 23845-23845/com.shawn.nichol.moviesstage2 D/doubleconvert: array[D@81ead05
    – morefaster
    Nov 13 '18 at 4:11










  • As you mentioned, Bundle doesn't support list of doubles. But it supports array of doubles, so you could try to convert the list to an array and put them in the Bundle, unless I misunderstood you?
    – Aaron
    Nov 13 '18 at 4:20










  • @morefaster By the way its double not Double if that's what you mean, otherwise other options will be converting those to Serializable or Parcelable, or even String.
    – Aaron
    Nov 13 '18 at 4:24










  • I just caught that two thinking that might the issue but I still get this response from the Log [D@a983e61.
    – morefaster
    Nov 13 '18 at 4:27






  • 1




    Were you trying to print by array.toString()? That'd only give you a hash value. If you want to print readable strings, then try Arrays.toString(array).
    – Aaron
    Nov 13 '18 at 4:36
















This didn't work for me unless I'm missing something. This is what the Log.d Prints back. D/doubleconvert: arrayList[6.6, 5.6, 8.3, 7.6, 6.0, 8.3, 7.5, 6.2, 5.3, 7.3, 6.9, 7.0, 6.6, 6.9, 5.5, 6.5, 6.4, 4.1, 6.1, 6.9] 2018-11-12 21:07:49.064 23845-23845/com.shawn.nichol.moviesstage2 D/doubleconvert: array[D@81ead05
– morefaster
Nov 13 '18 at 4:11




This didn't work for me unless I'm missing something. This is what the Log.d Prints back. D/doubleconvert: arrayList[6.6, 5.6, 8.3, 7.6, 6.0, 8.3, 7.5, 6.2, 5.3, 7.3, 6.9, 7.0, 6.6, 6.9, 5.5, 6.5, 6.4, 4.1, 6.1, 6.9] 2018-11-12 21:07:49.064 23845-23845/com.shawn.nichol.moviesstage2 D/doubleconvert: array[D@81ead05
– morefaster
Nov 13 '18 at 4:11












As you mentioned, Bundle doesn't support list of doubles. But it supports array of doubles, so you could try to convert the list to an array and put them in the Bundle, unless I misunderstood you?
– Aaron
Nov 13 '18 at 4:20




As you mentioned, Bundle doesn't support list of doubles. But it supports array of doubles, so you could try to convert the list to an array and put them in the Bundle, unless I misunderstood you?
– Aaron
Nov 13 '18 at 4:20












@morefaster By the way its double not Double if that's what you mean, otherwise other options will be converting those to Serializable or Parcelable, or even String.
– Aaron
Nov 13 '18 at 4:24




@morefaster By the way its double not Double if that's what you mean, otherwise other options will be converting those to Serializable or Parcelable, or even String.
– Aaron
Nov 13 '18 at 4:24












I just caught that two thinking that might the issue but I still get this response from the Log [D@a983e61.
– morefaster
Nov 13 '18 at 4:27




I just caught that two thinking that might the issue but I still get this response from the Log [D@a983e61.
– morefaster
Nov 13 '18 at 4:27




1




1




Were you trying to print by array.toString()? That'd only give you a hash value. If you want to print readable strings, then try Arrays.toString(array).
– Aaron
Nov 13 '18 at 4:36




Were you trying to print by array.toString()? That'd only give you a hash value. If you want to print readable strings, then try Arrays.toString(array).
– Aaron
Nov 13 '18 at 4:36


















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273256%2fonsavedinstancestate-doesnt-appear-to-support-double-array-list-what-are-my-opt%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python