公共游标无法解析符号

时间:2016-03-07 16:02:33

标签: java android sqlite

所以我试图获取我创建的SQL数据库的所有信息并在列表视图中显示它但是我遇到错误"无法解析符号TABLE_NAME"即使它被定义为页面顶部的公共静态字符串。

1.<link href="~/Content/bootstrap.css" rel="stylesheet" />
2.<link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
3.<link href="~/Content/AdminBootStrap.css" rel="stylesheet" />
4.<link href="~/Content/Site.css" rel="stylesheet" />
5.<link href="~/Content/reset.css" rel="stylesheet" />  <!-- CSS reset -->
6.<link href="~/Content/style.css" rel="stylesheet" /> <!-- Resource style -->
7.<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
8.<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!--End Bootstrap-->
<!--Start Scripts-->
9.<script src="~/Scripts/_references.js"></script>
10.<script src="~/Scripts/CustomJavaScript.js"></script>
11.<script src="~/Scripts/jquery-1.10.2.intellisense.js"></script>
12.<script src="~/Scripts/jquery-1.10.2.js"></script>
13.<script src="~/Scripts/jquery-1.10.2.min.js"></script>
14.<script src="~/Scripts/jquery-2.2.1.js"></script>
15.<script src="~/Scripts/jquery-2.2.1.min.js"></script>
16.<script src="~/Scripts/_references.js"></script>
17<script src="~/Scripts/jquery.validate-vsdoc.js"></script>
18.<script src="~/Scripts/jquery.validate.js"></script>
19.<script src="~/Scripts/jquery.validate.min.js"></script>
20.<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
21.<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
22.<script src="~/Scripts/bootstrap.js"></script>
23.<script src="~/Scripts/bootstrap.min.js"></script>
24.<script src="~/Scripts/modernizr-2.6.2.js"></script>
25.<script src="~/Scripts/respond.min.js"></script>
26.<script src="~/Scripts/respond.js"></script>
27.<script src="~/Scripts/jquery-2.1.1.js"></script>
28.<script src="~/Scripts/jquery.menu-aim.js"></script> <!-- menu aim -->
29.<script src="~/Scripts/main.js"></script>  <!-- Resource jQuery -->
30<script src="~/Scripts/modernizr.js"></script> <!-- Modernizr -->
<!--End Scripts-->

3 个答案:

答案 0 :(得分:1)

TABLE_NAME不是COL_1的属性。也许你的意思是

Cursor cursor = db.query(TABLE_NAME, projections, null, null, null, null, null);

答案 1 :(得分:0)

您正尝试访问COL_1.TABLE_NAME作为db.query()的参数。我建议删除COL_1.

答案 2 :(得分:0)

你需要创建一个表。

就像这样;

public class database_helper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "test.db";

    public static final String TABLE_NAME = "testtable";

    public static final String COL_1 = "ID";
    public static final String COL_2 = "NAME";
    public static final String COL_3 = "LASTNAME";
}