GreenDao integration with revision

I am looking for a solution that allows me to change jobs and GreenDao together.

This is my code and does not work.

Post is a class generated by the greenDao generator

EDIT: running this code returns me "retrofit.RetrofitError: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: expected BEGIN_ARRAY, but BEGIN_OBJECT in row 1 column 2 path $"

public static void test() {
    RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint(BASE_URL)
            .build();

    PostsInterface postsInterface = restAdapter.create(PostsInterface.class);

    Callback<List<Post>> callback = new Callback<List<Post>>() {
        @Override
        public void success(List<Post> posts, Response response) {
            Log.d(TAG, response.toString());
        }

        @Override
        public void failure(RetrofitError error) {
            Log.d(TAG, error.toString());
        }
    };

    postsInterface.getPosts(0, 10, callback);
}

public interface PostsInterface {
    @GET("/posts")
    void getPosts(@Query("start") int limit, @Query("count") int offset, Callback<List<Post>> callback);
}
+4
source share
2 answers

, Json, Json Array. , Post , , , .

0

: callback > callback

DAO daogenerator, DataPost, , .

DataPost ToMany.

@ToMany
@JoinEntity(entity = Post.class, sourceProperty = "id", targetProperty = "id")
public List<Post> yourPropertyNamefromJSON; //--> to make the name it has to be the same as the JSON response for example : 

JSON RESPONSE

{
  "success": true,
  "data": [
    {
      "name": "blah",
      "description": "blah"
    }]
 }


 public List<Post> data; //--> name have to be data

: 1 ??? : JSON "{" (Curly Bracket), , OBJECT.

!

!

0

All Articles