Android数组到mysql数据库?

I am having a seperate table of user interests. Then, for instance, my users table:

| uID | uName |
| 1   | Brad  |
| 2   | Jake  |

My interest table

| iID | iInterest |
| 1   | Cars      |
| 2   | Computers |

I have a many to many relationship table that links the users to the interests (UserInterests):

| uID | iID |
| 1   | 1   |
| 1   | 2   |
| 2   | 2   |

In my android app, I have an activity which contains checkboxes for each of the interest. Users can also choose multiple interest. For example Car, Computer, Technology etc. Whatever the user has selected will be stored in java userInterest arrayList. Now, how can I add that userInterest array to mysql. I really need some help!

If this were my project i would keep track of id's the user clicked on inside of an ArrayList. Set a listener on each checkbox that either add's or removes the Long object from the Arraylist. When the user is done, you can either iterate throw the ArrayList, calling insert on your database for each Long to add the iID.

An alternative would be to keep track of clicks with a SparseBooleanArray, this way you can keep track of position and if its "on" - True or "Off" False.

Another really cool way of doing this would be to implement the Command Design Pattern. You could store individual Insert/Delete commands inside your invoker object then call execute on each Command object.

Edit: The more I think about it, the more the command pattern would be really cool for this situation. It would also take care of any deletion as well as insertion if you implement it correctly. If the lists are huge you could run into performance problems doing individual inserts per row. You might also want to investigate a batch insert command (blanking on the SQL terminology...).