Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid and a RESTful service
    primarykey
    data
    text
    <p>I am trying to implement an app to utilize a RESTful web service. I've studied several different examples and have coded a good working app that does successful pulls from the REST service. But now I need some direction. Here's some basic background (very simplified)...</p> <ul> <li>Assume a basic REST service that has "GetReferrers" and "AddReferrer" methods.</li> <li>From the <code>Activity</code>, I call a <code>managedQuery</code> to get a <code>Cursor</code> back from the <code>ContentProvider</code> for my <code>ListView</code>.</li> <li>The <code>ContentProvider</code> returns back any local data, and calls an async "GetReferrers" to get the latest server list of referrers.</li> <li>I have a custom <code>ResponseHandler</code> to parse the JSON and insert it into the <code>ContentProvider</code>.</li> <li>As of now, I am deleting all records in the local <code>ContentProvider</code> upon a successful "get" from the server, then inserting the new/updated list to the database.</li> </ul> <p>Two questions I have are...</p> <ol> <li><p>When I do a new GET, would it be common practice to delete all the existing records in the local <code>ContentProvider</code> and insert the new list? Or would it be better (albeit more time consuming) to do checks for new/changed/deleted records to only add/change/delete, respectively?</p></li> <li><p>I really don't have any idea where to start on doing an "add" from the client to utilize the "AddReferrer" REST method. I know how to add a new item locally to the <code>ContentProvider</code> using <code>ContentValues</code> with a <code>getContentResolver().insert()</code>. But, where would I put the code to push that up to the server? Or would it be more common practice to skip adding to the local <code>ContentProvider</code>, push it up to the server, then let the GET pull it back to the local <code>ContentProvider</code>?</p></li> </ol> <p>Hope that all makes sense. I'd appreciate any direction you can give. If anybody knows of a good two-way example like this, please share. All examples of REST client operations I've found so far are just doing "gets" from the server and not pushes back up.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload