Save in Bmob (Android)

Source: Internet
Author: User

1 Find out first

2 saving data for the current table

3 updating data for associated tables

When inserting an associated data field, in order to detect whether or not to insert the problem repeatedly,

  /**     *  query whether there is a name that already exists      */     private void findnotegroupinfobyname ()  {         if  (Textutils.isempty (M_et_note_group_add_name.gettext (). toString (). Trim ()))  {             showtoast ("Name cannot be empty");             return;        }         bmobquery<notegroup> notegroups = new bmobquery <NoteGroup> ();         notegroups.addwhererelatedto ("NoteGroups",  new bmobpointer (MyUser));         notegroups.addwhereequalto ("Name",  m_et_note_group_add_name.gettext (). toString ());         Notegroups.findobjeCTS (This, new findlistener<notegroup> ()  {              @Override              Public void onsuccess (list<notegroup> notegroups)  {                 if  (Notegroups.size ()  == 0)  {                     savenotegroupinfo ();                 } else {                     showtoast ("already exists \" " + m_et_note_group_add_ Name.gettext (). toString ()  +  "\" Type ";                &nbSP;}             }               @Override              public void onerror (int i, string s)  {                 showerrorims (i);             }        });     }     /**     *  Save Note Group       */    private void savenotegroupinfo ()  {         notegroup = new notegroup ();         notegroup.setname (M_et_note_group_add_name.gettext (). toString ());         nOtegroup.setdescription (M_et_note_group_add_description.gettext (). toString ());         notegroup.setuser (MyUser);         notegroup.save ( This, new savelistener ()  {              @Override             public void  Onsuccess ()  {                 addnotegrouptouser ();            }               @Override              public void onfailure (int i, String s )  {                 Showerrorims (i);             }        });     }     /**     *  associating note groups to user      */    private void addnotegrouptouser ()  {         bmobrelation notegroups = new bmobrelation ();         notegroups.add (Notegroup);         myuser.setnotegroups (notegroups);         myuser.update ( This, new updatelistener ()  {              @Override             public void  Onsuccess ()  {                 bmobquery.clearallcaChedresults (Getapplicationcontext ());                 showtoast ("Save \" " + m_et_note_group_add_name.gettext (). toString ()  +   "\" Success ");            }               @Override              public void onfailure (int i, string s)  {                 showerrorims (i );            }         });     }


Save in Bmob (Android)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.