我正在致力于一个需要从本地Android资产目录访问Json数据的项目。我可以使用Volley Library阅读资产文件夹中的json数据,但我想用改装来做同样的事情。以下是我的json文件 - myfile.json
。使用改进方法从(本地)android资产文件夹获取Json数据
{
"formules": [
{
"formule": "Linear Motion",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Constant Acceleration Motion",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Projectile Motion",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Force",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Work, Power, Energy",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Rotary Motion",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Harmonic Motion",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Gravity",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Lateral and Longitudinal Waves",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Sound Waves",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Electrostatics",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Direct Current",
"url": "<html><body>You scored <b>192</b> points. <img src=\"http://192.168.1.46/shanta_holdings/img/images/project-thumbs/Glasshouse-1.jpg\" alt=\"Smiley face\"/></body></html> ",
"des":"Here is a description"
},
{
"formule": "Magnetic Field",
"url": "https://www.google.com/",
"des":"Here is a description"
},
{
"formule": "Alternating Current",
"url": "https://www.google.com/",
"des":"Here is a description"
},
{
"formule": "Thermodynamics",
"url": "https://www.google.com/",
"des":"Here is a description"
},
{
"formule": "Hydrogen Atom",
"url": "https://www.google.com/",
"des":"Here is a description"
},
{
"formule": "Optics",
"url": "https://www.google.com/",
"des":"Here is a description"
},
{
"formule": "Modern Physics",
"url": "https://www.google.com/",
"des":"Here is a description"
},
{
"formule": "Hydrostatics",
"url": "https://www.google.com/",
"des":"Here is a description"
},
{
"formule": "Astronomy",
"url": "https://www.google.com/",
"des":"Here is a description"
}
]
}
我搜索了一个星期,但没有得到任何适合的改造解决方案。我可以使用Retrofit从服务器读取数据。有什么方法可以使用改造来实现这一要求。
我觉得Volly和改造用于其他API不从资源文件夹,使用GSON转换JSON解析。 –
我有一个问题:**为什么?**为什么你想在不应该使用Volley和Retrofit的地方使用?为什么你不想直接加载文件? –