Confirmed users
975
edits
| Line 134: | Line 134: | ||
====Add a class to abstract querying your table from within Fennec==== | ====Add a class to abstract querying your table from within Fennec==== | ||
So instead of accessing the content provider directly, you can call, <tt>YourTable.insert(url, title);</tt>. Alternatively, add these methods directly to <tt>LocalBrowserDB</tt> & friends if your queries overlap the queries there or share data (e.g. table join). | So instead of accessing the content provider directly, you can call, <tt>YourTable.insert(url, title);</tt>. | ||
* | |||
Alternatively, add these methods directly to <tt>LocalBrowserDB</tt> & friends if your queries overlap the queries there or share data (e.g. table join). This method won't be discussed here. | |||
*Add a new interface for your class in <tt>omg.db</tt>. It should contain an <tt>insert*</tt> method with a <tt>ContentResolver</tt> arg and whatever else you want to insert. This method will likely need <tt>@RobocopTarget</tt> | |||
*Add a class implementing this interface. The current pattern for the class name is <tt>Local*</tt> (like <tt>LocalBrowserDB</tt>). The insert method should use the <tt>ContentResolver</tt> to talk insert via the <tt>BrowserProvider</tt> methods you previously implemented. | |||
*Add a <tt>getTableName</tt> method to the <tt>BrowserDB</tt> interface. It will like need <tt>@RobocopTarget</tt>. | |||
*Construct your class in the constructor of <tt>LocalBrowserDB</tt> and store it in a member variable. Add the implementation of your getter from above (also <tt>@RobocopTarget</tt>). | |||
*Add <tt>Stub* implements <your-interface></tt> to <tt>StubBrowserDB</tt> and have the implementation do nothing. Construct your <tt>Stub*</tt> with your member variable declaration and add the getter. | |||
*Don't forget to add your new files to <tt>moz.build</tt> | *Don't forget to add your new files to <tt>moz.build</tt> | ||