我在Android资源中有5个文件(test1,test2,test3,test4,test5)。应将所有资源分配给变量解析器。应该如何正确地完成?
公共类MainActivity扩展了Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
XmlResourceParser parser = getResources().getXml(R.xml.test1);
databaseHelper myDbHelper = new databaseHelper(this);
try {
//myDbHelper = new databaseHelper(this);
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("test") || name.equals("test")) {
String id = null, gname = null, pob = null, pob1 = null, memb = null, seq = null, site = null;
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
name = parser.getName();
if (name.equals("test")) {
id = readText(parser);
} else if (name.equals("test")) {