I have a Car class and it has brand name , price and uri for image. I have a recyler view in my main activity. I can store my brand name and my other strings in json file and show all strings in recyler view but how can I store and read uri and double in json file?
NewCar
var newCar = Car()
newCar.brandName = brandName.text.toString()
newCar.modelName = modelName.text.toString()
newCar.price = price.text.toString().toDouble()
newCar.fuelType = fuelType.text.toString()
newCar.gearType = gearType.text.toString()
newCar.km = kilometer.text.toString().toDouble()
newCar.image = imageUri
val callingActivity = activity as MainActivity?
callingActivity!!.createNewCar(newCar)
JSON Constructor
@Throws(JSONException::class)
constructor(jo: JSONObject) {
modelName = jo.getString(JSON_MODELNAME)
brandName = jo.getString(JSON_BRANDNAME)
fuelType = jo.getString(JSON_FUELTYPE)
km = jo.getDouble(JSON_KM)
price = jo.getDouble(JSON_PRICE)
color = jo.getString(JSON_COLOR)
gearType = jo.getString(JSON_GEARTYPE)
image = jo.get // what should I write here
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…