Java Android How to assemble a random database?

-1

In the Android application, using Java, I get a string in Json that looks like this:

String teste = "{\n" + " \"nometabela\":{\n" + " \"id\":\"f83d6101cc\",\n" + " \"coluna1\":\"codigo\",\n" + " \"coluna2\":\"descricao\",\"coluna3\":\"quantidade\"\n" + " }

With this data, I need to create the database using SQLite. For example, the data "table_name" inside the string Json will have to be the name of the table, the "id" will be "f83d6101cc", the name of the first column will be "code", the second "description" and the third "quantity ".

With the fixed data, I was able to create the bank.

However, the data will not always be this way. I will never know what this Json file will look like. The created bank will have to be based on it, so there may be more columns, or fewer columns, etc.

How do I read this String Json and create a bank according to the values passed by it? Thank you.

    
asked by anonymous 23.11.2018 / 12:03

1 answer

0

You can make your code recognize that each ":" passed by Json means a new column. And what's left of these points means the name of the table, and the right of its contents.

    
23.11.2018 / 21:03