How to store JSON object in SQLite database

前端 未结 5 2041
夕颜
夕颜 2020-12-04 08:29

how do I store a JSON Object in an SQLite database? What is the correct way?

one place is the blob type column. if i can convert the JSON object into byte array an

5条回答
  •  囚心锁ツ
    2020-12-04 08:42

    Convert JSONObject into String and save as TEXT/ VARCHAR. While retrieving the same column convert the String into JSONObject.

    For example

    Write into DB

    String stringToBeInserted = jsonObject.toString();
    //and insert this string into DB
    

    Read from DB

    String json = Read_column_value_logic_here
    JSONObject jsonObject = new JSONObject(json);
    

提交回复
热议问题