所以我将gson-2.2.4.jar添加到libs目录(我正在使用android studio).我的项目找不到gson的东西,所以我在"项目结构"中将它作为库依赖项添加到我的模块中.当我尝试运行该项目时,构建失败并出现以下错误:
Error:(12, 23) Gradle: package com.google.gson does not exist
Error:(37, 3) Gradle: cannot find symbol class Gson
Error:(37, 19) Gradle: cannot find symbol class Gson
Run Code Online (Sandbox Code Playgroud)
为什么我不能让这个工作?我在别处读到gradle应该自动处理所有内容,如果它放在lib目录中.
我需要将一个字符串数组保存到数据库,但它不会让我.这就是我所拥有的:
public long createEntry(String startTime, String endTime, String[] states) {
ContentValues initialValues = new ContentValues();
initialValues.put(START_KEY_TIME , startTime);
initialValues.put(END_KEY_TIME , endTime);
initialValues.put(KEY_STATE, states );
return databaseConnect.insert(DATABASE_TABLE, null, initialValues);
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我把string[]状态放入,它说内容值不能参与.我该如何解决这个问题?我以为我在状态中有7个东西,我可以喜欢有7个单独的字符串并在每个中存储东西然后将所有字符串放回字符串数组中吗?或者这是不好的做法?
我曾经拥有这种简单的JSON数据,我可以成功地解析属性并将它们保存到SQLite数据库中.
[
{
"project_title" : " ",
"organization_title" : " ",
"website": "",
"address": "",
"keyword" : "",
"short_code" : "",
"project_description" : "",
"smallImageUrl" : "",
"bigImageUrl" : "",
"price" : "",
"country" : "",
"donationAmount" : "",
"categories" : "",
"campaign_id" : "",
"currency_isoname": "",
"paypal_email" : "",
"elv_available" : ""
}
]
Run Code Online (Sandbox Code Playgroud)
但现在我有一个更复杂的JSON文件:
[
{
"location": {
"deleted_at": "null",
"documentary_video_length": "81",
"id": "15",
"latitude": "52.4134145988286",
"longitude": "13.0904620846177",
"position": "5",
"updated_at": "2011-08-26T15:30:27+02:00",
"name": "Glienicker Br\u00fccke",
"text": "",
"documentary_video_url": …Run Code Online (Sandbox Code Playgroud)