Getting conversations

Let's start by adding an endpoint to get all of the conversations on the phone, as follows:

    @GET 
    @Path("conversations") 
    public Response getConversations() { 
      List<Conversation> conversations = new ArrayList<>(); 
      Cursor cur = getApplication().getContentResolver() 
      .query(Telephony.Sms.Conversations.CONTENT_URI,  
      null, null, null, null); 
      while (cur.moveToNext()) { 
        conversations.add(buildConversation(cur)); 
      } 
 
      Collections.sort(conversations, new ConversationComparator()); 
 
      return Response.ok(new GenericEntity<List<Conversation>>( 
      conversations) {}).build(); 
     } 

Here is where we see the Android artifacts start to show up--we are going to use a ContentProvider to access the SMS data. A ContentProvider is a way for an application, ...

Get Java 9: Building Robust Modular Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.