0

I want to store this data into one table through one pojo class.so by this understanding I can relate it to two seprate tables.But as per requirement I have to save it in one table. I don't want to save it in to two seprate tables.How to achieve this ? (I just need the logic here.. I'm not expecting code leve)

EDIT PART

As you can see, there is no common parameter to relate this data in future from to seperate table

 {
        "createDate": 1339957800000,
        "modifyDate": 1341197519000,
        "createdBy": "aaa",
        "modifiedBy": "ddd",
        "status": "A",
        "description": "ffff",
        "parentId": null,
        "sourceId": null,
        "source_Field1": null,
        "source_Field2": null,
        "source_Field3": null,
        "source_Field4": null,
        "source_Field5": null,
        "parentKey": null,
        "parentValue": null,
        "genericMasterView":
        {
            "key": "MOD_ONE",
            "value": "195"
        }
    },
6
  • Any reason why it has to be a requirement of one table - from this its just a one to many relationship over 2 tables? Commented Nov 10, 2016 at 9:51
  • @cryptic this json have relation of one to many and should be stored in two table but also can be stored in one table but with redundant data if you want to i can demonstrate. Commented Nov 10, 2016 at 9:59
  • @cryptic: you can convert the json to string and save it in the db. While fetching, get the string data and convert it to the jsonobject :) Commented Nov 10, 2016 at 10:02
  • I have implemented volley here if(response!=null) { if(response.length>0) { DbHelper.getDatabase(SplashActivity.this).insertMasterData(Arrays.asList(response)); } } Usingt pojo class. Keeping similar name with respect to json respone body Commented Nov 10, 2016 at 10:09
  • @rana_sadam Please give your suggestion..Thanks Commented Nov 10, 2016 at 10:33

1 Answer 1

1

First Suggestion is create a table with 2 column one is Key and other is value Key contain any unique string key that represent ur data and value contain your json feed as string

Feed table screen shot

Other suggestion is to create a table with all keys as columns but the key genericMasterView would accommodate in 2 column genericMasterView_KEY and genericMasterView_value parse your json and enter the records in database. Hope this would help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.