88373

Create an array of items with Parse

Question:

I am able to store individual item into parse, where for instance a new column name ActivityName would be created with the activity name that the user have selected upon a button click, and when a user select a different activity the activityname under ActivityName would be changed. However, I do not want it to change, rather I want it to be added to the column of ActivityName, where you would have (activity1, activity2, activityn).

Below is the code I have used to store the individual activity name that gets replaced every time an activity is clicked.

@Override public void onClick(View v) { ParseUser currentUser = ParseUser.getCurrentUser(); // Create the class and the columns currentUser.saveInBackground(); currentUser.put("ActivityName", list_item_name); currentUser.put("ActivityPrice", list_item_price); currentUser.put("ActivityPurchasePriceCode", list_item_purchase_code); currentUser.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { setProgressBarIndeterminateVisibility(false); if (e == null) { // Success! Intent intent = new Intent(CasualEventsSingleItemActivity.this, usermatch.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } else { AlertDialog.Builder builder = new AlertDialog.Builder(CasualEventsSingleItemActivity.this); builder.setMessage(e.getMessage()) .setTitle(R.string.signup_error_title) .setPositiveButton(android.R.string.ok, null); AlertDialog dialog = builder.create(); dialog.show(); } } }); } });

I have tried using the following

currentUser.add("ActivityName", list_item_name); currentUser.add("ActivityPrice", list_item_price); currentUser.add("ActivityPurchasePriceCode", list_item_purchase_code);

but that have not been so successful, and below is the log cat message:

09-18 19:24:49.728: E/AndroidRuntime(4202): FATAL EXCEPTION: main 09-18 19:24:49.728: E/AndroidRuntime(4202): Process: com.dooba.beta, PID: 4202 09-18 19:24:49.728: E/AndroidRuntime(4202): java.lang.IllegalArgumentException: Operation is invalid after previous operation. 09-18 19:24:49.728: E/AndroidRuntime(4202): at com.parse.ParseAddOperation.apply(ParseAddOperation.java:75) 09-18 19:24:49.728: E/AndroidRuntime(4202): at com.parse.ParseObject.performOperation(ParseObject.java:2660) 09-18 19:24:49.728: E/AndroidRuntime(4202): at com.parse.ParseObject.addAll(ParseObject.java:2748) 09-18 19:24:49.728: E/AndroidRuntime(4202): at com.parse.ParseObject.add(ParseObject.java:2734) 09-18 19:24:49.728: E/AndroidRuntime(4202): at com.dooba.beta.CasualEventsSingleItemActivity$2.onClick(CasualEventsSingleItemActivity.java:119) 09-18 19:24:49.728: E/AndroidRuntime(4202): at android.view.View.performClick(View.java:4438) 09-18 19:24:49.728: E/AndroidRuntime(4202): at android.view.View$PerformClick.run(View.java:18422) 09-18 19:24:49.728: E/AndroidRuntime(4202): at android.os.Handler.handleCallback(Handler.java:733) 09-18 19:24:49.728: E/AndroidRuntime(4202): at android.os.Handler.dispatchMessage(Handler.java:95) 09-18 19:24:49.728: E/AndroidRuntime(4202): at android.os.Looper.loop(Looper.java:136) 09-18 19:24:49.728: E/AndroidRuntime(4202): at android.app.ActivityThread.main(ActivityThread.java:5017) 09-18 19:24:49.728: E/AndroidRuntime(4202): at java.lang.reflect.Method.invokeNative(Native Method) 09-18 19:24:49.728: E/AndroidRuntime(4202): at java.lang.reflect.Method.invoke(Method.java:515) 09-18 19:24:49.728: E/AndroidRuntime(4202): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 09-18 19:24:49.728: E/AndroidRuntime(4202): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 09-18 19:24:49.728: E/AndroidRuntime(4202): at dalvik.system.NativeStart.main(Native Method)

If you need any clarification, let me know. Thanks in advance

Answer1:

What you need to do is to declare a column as an array type and maybe copy the data from it , as for adding array to the beginning of the array , it is not possible to do that in with parse .

Recommend

  • The end of an integer line in C
  • ñ to Ñ string php
  • Why is favicon not visible
  • Parse SDK pinInBackground callback does not return
  • RecyclerView displaying the last item in the adapter several times. Need all adapter items to show i
  • Android: Parse.com concurrency issue with findInBackground()
  • Wcf Web API filter by DateTimeOffset
  • java.text.ParseException: Unparseable date: “2015-03-26 1624:32:39”
  • How to parse String to Date using FastDateFormat in a specified format
  • ParseQuery - Properly handling IndexOutOfBoundsException - Parse.com?
  • How to parse the values?
  • Pasring JSON data using Java
  • How to get the root path in Helper Class - Symfony2
  • Unexpected top level exception: bad class file magic, in Android
  • Capifony fails deploying
  • How to use offset time in Java Simple Date Format
  • Are XHTML self closing elements still valid in HTML5?
  • How do I solve a “java.lang.OutOfMemoryError: Java heap space”?
  • Curl and relative path in
  • Eclipse Sequoyah Cannot debug native JNI code: No connection machine actively refused it
  • Java skip try catch for throwable fuction
  • Convert ArrayList of String type into Date type?
  • Converting date string to another string [duplicate]
  • Proguard ParseException unknown option dump.txt
  • Convert Java string to Time, NOT Date [duplicate]
  • Trouble doing simple parse in pyparsing
  • ParseException: Invalid session token error
  • Android date format parse throwing an Unhandled Exception
  • Changing Java Timestamp format causes a change of the timestamp
  • How to show Firestore serverTimestamp correctly depending on local
  • Format Date Java
  • find the repetition of duplicate numbers
  • ParseException - Can't figure out the right pattern
  • Perl - Using regex to match input in hash key or value
  • Java scrap website with login required using Jsoup
  • Parsing date string (MM-dd) to java date in default year
  • How to make JDatePicker text field formatted for input?
  • In javascript, what is a constructor? And what isn't?
  • java program to calculate XIRR without using excel or any other library
  • Android Studio and gradle