广州地铁离线查询app源码
原创代码,转载请标明出处http://1.crazychen.sinaapp.com/?p=529
package com.example.station;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
private AutoCompleteTextView sstation;//起点站
private AutoCompleteTextView estation;//终点站
private Button check;
private String answer = "";
MainActivity my = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sstation = (AutoCompleteTextView) findViewById(R.id.sstation);
estation = (AutoCompleteTextView) findViewById(R.id.estation);
//判断是否建表
if(this.getSharedPreferences("table", Context.MODE_PRIVATE).getString("table", "").equals("")){
CreatTable.creattable();
Editor e = this.getSharedPreferences("table", Context.MODE_PRIVATE).edit();
e.putString("table", "write");
e.commit();
}
//获取所有地铁站的名称
String[] stations = DB.getAllStations();
//为自动提示配置适配器
sstation.setAdapter(new ArrayAdapter(this, R.layout.list_item,stations));
sstation.setAdapter(new ArrayAdapter(this, R.layout.list_item,stations));
check = (Button) findViewById(R.id.check);
//查询按钮点击
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int start = 0;
int end = 0;
int head = 0;
int rear = 1;
int temp = 0;
//检查是否输入起点站
if(sstation.getText().toString().equals("")){
Toast.makeText(MainActivity.this, "起点不能为空", Toast.LENGTH_SHORT).show();
return;
}else{
end = DB.getStationId(sstation.getText().toString().trim());
if(end==0){
Toast.makeText(MainActivity.this, "起点不存在", Toast.LENGTH_SHORT).show();
return;
}
}
//检查是否输入终点站
if(estation.getText().toString().equals("")){
Toast.makeText(MainActivity.this, "终点不能为空", Toast.LENGTH_SHORT).show();
return;
}else{
start = DB.getStationId(estation.getText().toString().trim());
if(start==0){
Toast.makeText(MainActivity.this, "终点不存在", Toast.LENGTH_SHORT).show();
return;
}
}
//检查起点终点是否相同
if(start == end){
Toast.makeText(MainActivity.this, "起点与终点相同", Toast.LENGTH_SHORT).show();
return;
}
temp = DB.getTotal();//获取地铁站的数目
int[] stack = new int[temp];//栈
boolean[] find = new boolean[temp];//标记某地铁站是否被查找过了
int[] pre = new int[temp];//用于记录某站的前一站的id
//初始化起点站信息
stack[0] = start;
pre[0] = 0;
find[start] = true;
Cursor cur = null;
SQLiteDatabase sld = null;
while(head!=rear){
/**
* 下面两端代码相似度高
* 其实就是分别查询头尾
*/
/****************************/
sld = DB.createOrOpenDatabase();//连接数据库
cur=sld.rawQuery("select eid from sta_to_sta where sid="+start, new String[]{});//查询与该站连接的站点id
while(cur.moveToNext()){//循环处理相邻站
temp = cur.getInt(cur.getColumnIndex("eid"));
if(!find[temp]){
pre[rear] = head;//将当前站设为相邻站的前一个站
stack[rear] = temp;//将相邻站入栈
find[temp] = true;//标记改相邻站已被查询
if(temp==end){//判断该相邻站是否是终点站
temp = rear;
while(temp!=0){
cur.close();
sld.close();
sld = DB.createOrOpenDatabase();
cur=sld.rawQuery("select name,line from station where id="+stack[temp], new String[]{});//根据id获取站名
cur.moveToFirst();
answer += cur.getString(cur.getColumnIndex("name"))+"("+cur.getString(cur.getColumnIndex("line"))+")---->";
temp = pre[temp];//获得前一个站的id
}
cur.close();
sld.close();
sld = DB.createOrOpenDatabase();
//最后在重复一次上述过程
cur=sld.rawQuery("select name,line from station where id="+stack[temp], new String[]{});
cur.moveToFirst();
answer += cur.getString(cur.getColumnIndex("name"))+"("+cur.getString(cur.getColumnIndex("line"))+")";
cur.close();
sld.close();
goToShow();//跳转到结果展示页面
return;
}
rear++;
}
}
cur.close();
sld.close();
/****************************/
/****************************/
sld = DB.createOrOpenDatabase();
cur=sld.rawQuery("select sid from sta_to_sta where eid="+start, new String[]{});//查询与该站连接的站点id
while(cur.moveToNext()){
temp = cur.getInt(cur.getColumnIndex("sid"));
if(!find[temp]){
pre[rear] = head;
stack[rear] = temp;
find[temp] = true;
if(temp==end){
temp = rear;
while(temp!=0){
cur.close();
sld.close();
sld = DB.createOrOpenDatabase();
cur = sld.rawQuery("select name,line from station where id="+stack[temp], new String[]{});
cur.moveToFirst();
answer += cur.getString(cur.getColumnIndex("name"))+"("+cur.getString(cur.getColumnIndex("line"))+")---->";
temp = pre[temp];
}
cur.close();
sld.close();
sld = DB.createOrOpenDatabase();
cur = sld.rawQuery("select name,line from station where id="+stack[temp], new String[]{});
cur.moveToFirst();
answer += cur.getString(cur.getColumnIndex("name"))+"("+cur.getString(cur.getColumnIndex("line"))+")";
cur.close();
sld.close();
goToShow();
return;
}
rear++;
}
}
cur.close();
sld.close();
/****************************/
head++;
start = stack[head];
}
}
});
}
//主界面返回按钮,结束程序
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
System.exit(0);
}
return true;
}
//跳转到结果展示页面
public void goToShow(){
Intent i = new Intent(MainActivity.this,ShowActivity.class);
i.putExtra("answer", answer);
answer="";
startActivity(i);
}
}
DB:
package com.example.station;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public class DB {
public static SQLiteDatabase createOrOpenDatabase()//连接数据库
{
SQLiteDatabase sld=null;
try{
sld=SQLiteDatabase.openDatabase//连接并创建数据库,如果不存在则创建
(
"data/data/com.example.station/mydb",
null,
SQLiteDatabase.OPEN_READWRITE|SQLiteDatabase.CREATE_IF_NECESSARY);
}catch(Exception e)
{
e.printStackTrace();
}
return sld;//返回该连接
}
public static void createTable(String sql){//创建表
SQLiteDatabase sld=createOrOpenDatabase();//连接数据库
try{
sld.execSQL(sql);//执行SQL语句
sld.close();//关闭连接
}catch(Exception e){
System.out.println("创建失败");
}
}
public static int getTotal(){
int total=0;
SQLiteDatabase sld=createOrOpenDatabase();//连接数据库
String sql = "select count(*) from station";
Cursor cur=sld.rawQuery(sql, new String[]{});
//查看结果集
if(cur.moveToNext()){
total = cur.getInt(0);
}
//关闭结果集,语句及连接
cur.close();
sld.close();
return total;
}
public static String[] getAllStations(){
String[] str;
int i = 0;
SQLiteDatabase sld=createOrOpenDatabase();//连接数据库
String sql = "select name from station";
Cursor cur=sld.rawQuery(sql, new String[]{});
str = new String[cur.getCount()];
for(cur.moveToFirst();!cur.isAfterLast();cur.moveToNext())
{
str[i] = cur.getString(cur.getColumnIndex("name"));
i++;
}
//关闭结果集,语句及连接
cur.close();
sld.close();
return str;
}
public static int getStationId(String name){
int id=0;
SQLiteDatabase sld=createOrOpenDatabase();//连接数据库
String sql = "select id from station where name='"+name+"'";
Cursor cur=sld.rawQuery(sql, new String[]{});
//查看结果集
if(cur.moveToNext()){
id = cur.getInt(0);
}
return id;
}
public static Cursor executeQuery(String sql){
SQLiteDatabase sld=DB.createOrOpenDatabase();
Cursor cur=sld.rawQuery(sql, new String[]{});
return cur;
}
}
CreateTable
package com.example.station;
public class CreatTable {
public static void creattable(){
try{
String sqll[]=new String[]{
"drop table if exists station",
"drop table if exists sta_to_sta",
"create table if not exists station(id integer primary key," +
"name char(100),line char(100))",//建立station表
"create table if not exists sta_to_sta" +
"(id integer primary key,sid integer,eid integer)",//建立relation表
//插入一些初始化数据
"INSERT INTO 'station' VALUES ('1', '广州东站', '中转站')",
"INSERT INTO 'station' VALUES ('2', '体育中心', '中转站')",
"INSERT INTO 'station' VALUES ('3', '林和西', '中转站')",
"INSERT INTO 'station' VALUES ('4', '燕塘', '中转站')",
"INSERT INTO 'station' VALUES ('5', '体育中心南', 'APM线')",
"INSERT INTO 'station' VALUES ('6', '体育西路', '中转站')",
"INSERT INTO 'station' VALUES ('7', '石牌桥', '3号线')",
"INSERT INTO 'station' VALUES ('8', '杨箕', '中转站')",
"INSERT INTO 'station' VALUES ('9', '珠江新城', '中转站')",
"INSERT INTO 'station' VALUES ('10', '五羊邨', '3号线')",
"INSERT INTO 'station' VALUES ('11', '广州塔', '中转站')",
"INSERT INTO 'station' VALUES ('12', '猎德', '5号线')",
"INSERT INTO 'station' VALUES ('13', '海心沙', 'APM线')",
"INSERT INTO 'station' VALUES ('14', '客村', '中转站')",
"INSERT INTO 'station' VALUES ('15', '鹭江', '8号线')",
"INSERT INTO 'station' VALUES ('16', '赤岗', '5号线')",
"INSERT INTO 'station' VALUES ('17', '大塘', '3号线')",
"INSERT INTO 'station' VALUES ('18', '车陂南', '中转站')",
"INSERT INTO 'station' VALUES ('19', '科韵路', '5号线')",
"INSERT INTO 'station' VALUES ('20', '车陂', '4号线')",
"INSERT INTO 'station' VALUES ('21', '东圃', '4号线')",
"INSERT INTO 'station' VALUES ('22', '万胜围', '中转站')",
"INSERT INTO 'station' VALUES ('23', '琶洲', '8号线')",
"INSERT INTO 'station' VALUES ('24', '官洲', '4号线')",
"INSERT INTO 'station' VALUES ('25', '天河客运站', '中转站')",
"INSERT INTO 'station' VALUES ('26', '五山', '3号线')",
"INSERT INTO 'station' VALUES ('27', '长湴', '6号线')",
"INSERT INTO 'station' VALUES ('28', '天平架', '6号线')",
"INSERT INTO 'station' VALUES ('29', '梅花园', '3号线')",
"INSERT INTO 'station' VALUES ('30', '动物园', '5号线')",
"INSERT INTO 'station' VALUES ('31', '东山口', '中转站')",
"INSERT INTO 'station' VALUES ('32', '区庄', '中转站')",
"INSERT INTO 'station' VALUES ('33', '淘金', '5号线')",
"INSERT INTO 'station' VALUES ('34', '东湖', '6号线')",
"INSERT INTO 'station' VALUES ('35', '烈士陵园', '1号线')",
"INSERT INTO 'station' VALUES ('36', '嘉禾望岗', '中转站')",
"INSERT INTO 'station' VALUES ('37', '黄边', '2号线')",
"INSERT INTO 'station' VALUES ('38', '龙归', '3号线')",
"INSERT INTO 'station' VALUES ('39', '白云大道北', '3号线')",
"INSERT INTO 'station' VALUES ('40', '广州火车站', '中转站')",
"INSERT INTO 'station' VALUES ('41', '三元里', '2号线')",
"INSERT INTO 'station' VALUES ('42', '西村', '5号线')",
"INSERT INTO 'station' VALUES ('43', '小北', '5号线')",
"INSERT INTO 'station' VALUES ('44', '越秀公园', '2号线')",
"INSERT INTO 'station' VALUES ('45', '公元前', '中转站')",
"INSERT INTO 'station' VALUES ('46', '纪念堂', '2号线')",
"INSERT INTO 'station' VALUES ('47', '西门口', '1号线')",
"INSERT INTO 'station' VALUES ('48', '农讲所', '1号线')",
"INSERT INTO 'station' VALUES ('49', '海珠广场', '中转站')",
"INSERT INTO 'station' VALUES ('50', '北京路', '6号线')",
"INSERT INTO 'station' VALUES ('51', '市二宫', '2号线')",
"INSERT INTO 'station' VALUES ('52', '文化公园', '6号线')",
"INSERT INTO 'station' VALUES ('53', '昌岗', '中转站')",
"INSERT INTO 'station' VALUES ('54', '江南西', '2号线')",
"INSERT INTO 'station' VALUES ('55', '宝岗大道', '8号线')",
"INSERT INTO 'station' VALUES ('56', '晓港', '8号线')",
"INSERT INTO 'station' VALUES ('57', '江泰路', '2号线')",
"INSERT INTO 'station' VALUES ('58', '坦尾', '中转站')",
"INSERT INTO 'station' VALUES ('59', '滘口', '5号线')",
"INSERT INTO 'station' VALUES ('60', '河沙', '6号线')",
"INSERT INTO 'station' VALUES ('61', '中山八', '5号线')",
"INSERT INTO 'station' VALUES ('62', '如意坊', '6号线')",
"INSERT INTO 'station' VALUES ('63', '黄沙', '中转站')",
"INSERT INTO 'station' VALUES ('64', '长寿路', '1号线')",
"INSERT INTO 'station' VALUES ('65', '沙河顶', '6号线')",
"INSERT INTO 'station' VALUES ('66', '芳村', '1号线')",
"INSERT INTO 'station' VALUES ('67', '黄花岗', '6号线')",
"INSERT INTO 'station' VALUES ('68', '团一大广场', '6号线')",
"INSERT INTO 'station' VALUES ('69', '沙贝', '6号线')",
"INSERT INTO 'station' VALUES ('70', '横沙', '6号线')",
"INSERT INTO 'station' VALUES ('71', '浔峰岗', '6号线')",
"INSERT INTO 'station' VALUES ('72', '文冲', '5号线')",
"INSERT INTO 'station' VALUES ('73', '大沙东', '5号线')",
"INSERT INTO 'station' VALUES ('74', '大沙地', '5号线')",
"INSERT INTO 'station' VALUES ('75', '鱼珠', '5号线')",
"INSERT INTO 'station' VALUES ('76', '三溪', '5号线')",
"INSERT INTO 'station' VALUES ('77', '员村', '5号线')",
"INSERT INTO 'station' VALUES ('79', '潭村', '5号线')",
"INSERT INTO 'station' VALUES ('80', '西场', '5号线')",
"INSERT INTO 'station' VALUES ('81', '黄村', '4号线')",
"INSERT INTO 'station' VALUES ('82', '大学城北', '4号线')",
"INSERT INTO 'station' VALUES ('83', '大学城南', '4号线')",
"INSERT INTO 'station' VALUES ('84', '新造', '4号线')",
"INSERT INTO 'station' VALUES ('85', '石碁', '4号线')",
"INSERT INTO 'station' VALUES ('86', '海傍', '4号线')",
"INSERT INTO 'station' VALUES ('87', '低涌', '4号线')",
"INSERT INTO 'station' VALUES ('88', '东涌', '4号线')",
"INSERT INTO 'station' VALUES ('89', '黄阁汽车城', '4号线')",
"INSERT INTO 'station' VALUES ('90', '黄阁', '4号线')",
"INSERT INTO 'station' VALUES ('91', '蕉门', '4号线')",
"INSERT INTO 'station' VALUES ('92', '金洲', '4号线')",
"INSERT INTO 'station' VALUES ('93', '新港东', '8号线')",
"INSERT INTO 'station' VALUES ('94', '磨碟沙', '8号线')",
"INSERT INTO 'station' VALUES ('95', '中大', '8号线')",
"INSERT INTO 'station' VALUES ('96', '沙园', '8号线')",
"INSERT INTO 'station' VALUES ('97', '凤凰新村', '8号线')",
"INSERT INTO 'station' VALUES ('98', '华师', '3号线')",
"INSERT INTO 'station' VALUES ('99', '岗顶', '3号线')",
"INSERT INTO 'station' VALUES ('100', '机场南', '3号线')",
"INSERT INTO 'station' VALUES ('101', '人和', '3号线')",
"INSERT INTO 'station' VALUES ('102', '永泰', '3号线')",
"INSERT INTO 'station' VALUES ('103', '同和', '3号线')",
"INSERT INTO 'station' VALUES ('104', '京溪南方医院', '3号线')",
"INSERT INTO 'station' VALUES ('105', '沥滘', '3号线')",
"INSERT INTO 'station' VALUES ('106', '厦滘', '3号线')",
"INSERT INTO 'station' VALUES ('107', '大石', '3号线')",
"INSERT INTO 'station' VALUES ('108', '汉溪长隆', '3号线')",
"INSERT INTO 'station' VALUES ('109', '市桥', '3号线')",
"INSERT INTO 'station' VALUES ('110', '番禺广场', '3号线')",
"INSERT INTO 'station' VALUES ('111', '江夏', '2号线')",
"INSERT INTO 'station' VALUES ('112', '萧岗', '2号线')",
"INSERT INTO 'station' VALUES ('113', '白云文化广场', '2号线')",
"INSERT INTO 'station' VALUES ('114', '白云公园', '2号线')",
"INSERT INTO 'station' VALUES ('115', '飞翔公园', '2号线')",
"INSERT INTO 'station' VALUES ('116', '东晓南', '2号线')",
"INSERT INTO 'station' VALUES ('117', '南洲', '2号线')",
"INSERT INTO 'station' VALUES ('118', '洛溪', '2号线')",
"INSERT INTO 'station' VALUES ('119', '南浦', '2号线')",
"INSERT INTO 'station' VALUES ('120', '会江', '2号线')",
"INSERT INTO 'station' VALUES ('121', '石壁', '2号线')",
"INSERT INTO 'station' VALUES ('122', '广州南站', '2号线')",
"INSERT INTO 'station' VALUES ('123', '陈家祠', '1号线')",
"INSERT INTO 'station' VALUES ('124', '花地湾', '1号线')",
"INSERT INTO 'station' VALUES ('125', '坑口', '1号线')",
"INSERT INTO 'station' VALUES ('126', '西朗', '中转站')",
"INSERT INTO 'station' VALUES ('127', '菊树', '广佛线')",
"INSERT INTO 'station' VALUES ('128', '龙溪', '广佛线')",
"INSERT INTO 'station' VALUES ('129', '金融新高区', '广佛线')",
"INSERT INTO 'station' VALUES ('130', '千灯湖', '广佛线')",
"INSERT INTO 'station' VALUES ('131', '礌岗', '广佛线')",
"INSERT INTO 'station' VALUES ('132', '南桂路', '广佛线')",
"INSERT INTO 'station' VALUES ('133', '桂城', '广佛线')",
"INSERT INTO 'station' VALUES ('134', '朝安', '广佛线')",
"INSERT INTO 'station' VALUES ('135', '普君北路', '广佛线')",
"INSERT INTO 'station' VALUES ('136', '祖庙', '广佛线')",
"INSERT INTO 'station' VALUES ('137', '同济路', '广佛线')",
"INSERT INTO 'station' VALUES ('138', '季华园', '广佛线')",
"INSERT INTO 'station' VALUES ('139', '魁奇路', '广佛线')",
"INSERT INTO 'sta_to_sta' VALUES ('1', '1', '2')",
"INSERT INTO 'sta_to_sta' VALUES ('2', '1', '3')",
"INSERT INTO 'sta_to_sta' VALUES ('3', '1', '4')",
"INSERT INTO 'sta_to_sta' VALUES ('4', '4', '5')",
"INSERT INTO 'sta_to_sta' VALUES ('5', '3', '6')",
"INSERT INTO 'sta_to_sta' VALUES ('6', '2', '6')",
"INSERT INTO 'sta_to_sta' VALUES ('7', '6', '7')",
"INSERT INTO 'sta_to_sta' VALUES ('8', '6', '8')",
"INSERT INTO 'sta_to_sta' VALUES ('9', '6', '9')",
"INSERT INTO 'sta_to_sta' VALUES ('10', '8', '10')",
"INSERT INTO 'sta_to_sta' VALUES ('11', '9', '10')",
"INSERT INTO 'sta_to_sta' VALUES ('12', '9', '11')",
"INSERT INTO 'sta_to_sta' VALUES ('13', '9', '12')",
"INSERT INTO 'sta_to_sta' VALUES ('14', '11', '13')",
"INSERT INTO 'sta_to_sta' VALUES ('15', '11', '14')",
"INSERT INTO 'sta_to_sta' VALUES ('16', '14', '15')",
"INSERT INTO 'sta_to_sta' VALUES ('17', '14', '16')",
"INSERT INTO 'sta_to_sta' VALUES ('18', '14', '17')",
"INSERT INTO 'sta_to_sta' VALUES ('19', '18', '19')",
"INSERT INTO 'sta_to_sta' VALUES ('20', '18', '20')",
"INSERT INTO 'sta_to_sta' VALUES ('21', '18', '21')",
"INSERT INTO 'sta_to_sta' VALUES ('22', '18', '22')",
"INSERT INTO 'sta_to_sta' VALUES ('23', '22', '23')",
"INSERT INTO 'sta_to_sta' VALUES ('24', '22', '24')",
"INSERT INTO 'sta_to_sta' VALUES ('25', '4', '25')",
"INSERT INTO 'sta_to_sta' VALUES ('26', '25', '26')",
"INSERT INTO 'sta_to_sta' VALUES ('27', '25', '27')",
"INSERT INTO 'sta_to_sta' VALUES ('28', '4', '28')",
"INSERT INTO 'sta_to_sta' VALUES ('29', '4', '29')",
"INSERT INTO 'sta_to_sta' VALUES ('30', '8', '30')",
"INSERT INTO 'sta_to_sta' VALUES ('31', '8', '31')",
"INSERT INTO 'sta_to_sta' VALUES ('32', '31', '32')",
"INSERT INTO 'sta_to_sta' VALUES ('33', '30', '32')",
"INSERT INTO 'sta_to_sta' VALUES ('34', '32', '33')",
"INSERT INTO 'sta_to_sta' VALUES ('35', '31', '34')",
"INSERT INTO 'sta_to_sta' VALUES ('36', '31', '35')",
"INSERT INTO 'sta_to_sta' VALUES ('37', '36', '37')",
"INSERT INTO 'sta_to_sta' VALUES ('38', '36', '38')",
"INSERT INTO 'sta_to_sta' VALUES ('39', '36', '39')",
"INSERT INTO 'sta_to_sta' VALUES ('40', '40', '41')",
"INSERT INTO 'sta_to_sta' VALUES ('41', '40', '42')",
"INSERT INTO 'sta_to_sta' VALUES ('42', '40', '43')",
"INSERT INTO 'sta_to_sta' VALUES ('43', '40', '44')",
"INSERT INTO 'sta_to_sta' VALUES ('44', '45', '46')",
"INSERT INTO 'sta_to_sta' VALUES ('45', '45', '47')",
"INSERT INTO 'sta_to_sta' VALUES ('46', '45', '48')",
"INSERT INTO 'sta_to_sta' VALUES ('47', '45', '49')",
"INSERT INTO 'sta_to_sta' VALUES ('48', '49', '50')",
"INSERT INTO 'sta_to_sta' VALUES ('49', '49', '51')",
"INSERT INTO 'sta_to_sta' VALUES ('50', '49', '52')",
"INSERT INTO 'sta_to_sta' VALUES ('51', '53', '54')",
"INSERT INTO 'sta_to_sta' VALUES ('52', '53', '55')",
"INSERT INTO 'sta_to_sta' VALUES ('53', '53', '56')",
"INSERT INTO 'sta_to_sta' VALUES ('54', '53', '57')",
"INSERT INTO 'sta_to_sta' VALUES ('55', '58', '59')",
"INSERT INTO 'sta_to_sta' VALUES ('56', '58', '60')",
"INSERT INTO 'sta_to_sta' VALUES ('57', '58', '61')",
"INSERT INTO 'sta_to_sta' VALUES ('58', '58', '62')",
"INSERT INTO 'sta_to_sta' VALUES ('59', '62', '63')",
"INSERT INTO 'sta_to_sta' VALUES ('60', '63', '64')",
"INSERT INTO 'sta_to_sta' VALUES ('61', '63', '52')",
"INSERT INTO 'sta_to_sta' VALUES ('62', '63', '66')",
"INSERT INTO 'sta_to_sta' VALUES ('63', '65', '67')",
"INSERT INTO 'sta_to_sta' VALUES ('64', '32', '67')",
"INSERT INTO 'sta_to_sta' VALUES ('65', '34', '68')",
"INSERT INTO 'sta_to_sta' VALUES ('66', '50', '68')",
"INSERT INTO 'sta_to_sta' VALUES ('67', '60', '69')",
"INSERT INTO 'sta_to_sta' VALUES ('68', '69', '70')",
"INSERT INTO 'sta_to_sta' VALUES ('69', '69', '71')",
"INSERT INTO 'sta_to_sta' VALUES ('70', '72', '73')",
"INSERT INTO 'sta_to_sta' VALUES ('71', '73', '74')",
"INSERT INTO 'sta_to_sta' VALUES ('72', '74', '75')",
"INSERT INTO 'sta_to_sta' VALUES ('73', '75', '76')",
"INSERT INTO 'sta_to_sta' VALUES ('74', '21', '76')",
"INSERT INTO 'sta_to_sta' VALUES ('75', '19', '77')",
"INSERT INTO 'sta_to_sta' VALUES ('76', '77', '79')",
"INSERT INTO 'sta_to_sta' VALUES ('77', '12', '79')",
"INSERT INTO 'sta_to_sta' VALUES ('78', '42', '80')",
"INSERT INTO 'sta_to_sta' VALUES ('79', '61', '80')",
"INSERT INTO 'sta_to_sta' VALUES ('80', '20', '81')",
"INSERT INTO 'sta_to_sta' VALUES ('81', '24', '82')",
"INSERT INTO 'sta_to_sta' VALUES ('82', '82', '83')",
"INSERT INTO 'sta_to_sta' VALUES ('83', '83', '84')",
"INSERT INTO 'sta_to_sta' VALUES ('84', '84', '85')",
"INSERT INTO 'sta_to_sta' VALUES ('85', '85', '86')",
"INSERT INTO 'sta_to_sta' VALUES ('86', '86', '87')",
"INSERT INTO 'sta_to_sta' VALUES ('87', '87', '88')",
"INSERT INTO 'sta_to_sta' VALUES ('88', '88', '89')",
"INSERT INTO 'sta_to_sta' VALUES ('89', '89', '90')",
"INSERT INTO 'sta_to_sta' VALUES ('90', '90', '91')",
"INSERT INTO 'sta_to_sta' VALUES ('91', '91', '92')",
"INSERT INTO 'sta_to_sta' VALUES ('92', '23', '93')",
"INSERT INTO 'sta_to_sta' VALUES ('93', '93', '94')",
"INSERT INTO 'sta_to_sta' VALUES ('94', '16', '94')",
"INSERT INTO 'sta_to_sta' VALUES ('95', '15', '95')",
"INSERT INTO 'sta_to_sta' VALUES ('96', '56', '95')",
"INSERT INTO 'sta_to_sta' VALUES ('97', '55', '96')",
"INSERT INTO 'sta_to_sta' VALUES ('98', '96', '97')",
"INSERT INTO 'sta_to_sta' VALUES ('99', '26', '98')",
"INSERT INTO 'sta_to_sta' VALUES ('100', '98', '99')",
"INSERT INTO 'sta_to_sta' VALUES ('101', '7', '99')",
"INSERT INTO 'sta_to_sta' VALUES ('102', '100', '101')",
"INSERT INTO 'sta_to_sta' VALUES ('103', '38', '101')",
"INSERT INTO 'sta_to_sta' VALUES ('104', '39', '102')",
"INSERT INTO 'sta_to_sta' VALUES ('105', '102', '103')",
"INSERT INTO 'sta_to_sta' VALUES ('106', '103', '104')",
"INSERT INTO 'sta_to_sta' VALUES ('107', '29', '104')",
"INSERT INTO 'sta_to_sta' VALUES ('108', '17', '105')",
"INSERT INTO 'sta_to_sta' VALUES ('109', '105', '106')",
"INSERT INTO 'sta_to_sta' VALUES ('110', '106', '107')",
"INSERT INTO 'sta_to_sta' VALUES ('111', '107', '108')",
"INSERT INTO 'sta_to_sta' VALUES ('112', '108', '109')",
"INSERT INTO 'sta_to_sta' VALUES ('113', '109', '110')",
"INSERT INTO 'sta_to_sta' VALUES ('114', '37', '111')",
"INSERT INTO 'sta_to_sta' VALUES ('115', '111', '112')",
"INSERT INTO 'sta_to_sta' VALUES ('116', '112', '113')",
"INSERT INTO 'sta_to_sta' VALUES ('117', '113', '114')",
"INSERT INTO 'sta_to_sta' VALUES ('118', '114', '115')",
"INSERT INTO 'sta_to_sta' VALUES ('119', '41', '115')",
"INSERT INTO 'sta_to_sta' VALUES ('120', '44', '46')",
"INSERT INTO 'sta_to_sta' VALUES ('121', '51', '54')",
"INSERT INTO 'sta_to_sta' VALUES ('122', '57', '116')",
"INSERT INTO 'sta_to_sta' VALUES ('123', '116', '117')",
"INSERT INTO 'sta_to_sta' VALUES ('124', '117', '118')",
"INSERT INTO 'sta_to_sta' VALUES ('125', '118', '119')",
"INSERT INTO 'sta_to_sta' VALUES ('126', '119', '120')",
"INSERT INTO 'sta_to_sta' VALUES ('127', '120', '121')",
"INSERT INTO 'sta_to_sta' VALUES ('128', '121', '122')",
"INSERT INTO 'sta_to_sta' VALUES ('129', '35', '48')",
"INSERT INTO 'sta_to_sta' VALUES ('130', '47', '123')",
"INSERT INTO 'sta_to_sta' VALUES ('131', '64', '123')",
"INSERT INTO 'sta_to_sta' VALUES ('132', '66', '124')",
"INSERT INTO 'sta_to_sta' VALUES ('133', '124', '125')",
"INSERT INTO 'sta_to_sta' VALUES ('134', '125', '126')",
"INSERT INTO 'sta_to_sta' VALUES ('135', '126', '127')",
"INSERT INTO 'sta_to_sta' VALUES ('136', '127', '128')",
"INSERT INTO 'sta_to_sta' VALUES ('137', '128', '129')",
"INSERT INTO 'sta_to_sta' VALUES ('138', '129', '130')",
"INSERT INTO 'sta_to_sta' VALUES ('139', '130', '131')",
"INSERT INTO 'sta_to_sta' VALUES ('140', '131', '132')",
"INSERT INTO 'sta_to_sta' VALUES ('141', '132', '133')",
"INSERT INTO 'sta_to_sta' VALUES ('142', '133', '134')",
"INSERT INTO 'sta_to_sta' VALUES ('143', '134', '135')",
"INSERT INTO 'sta_to_sta' VALUES ('144', '135', '136')",
"INSERT INTO 'sta_to_sta' VALUES ('145', '136', '137')",
"INSERT INTO 'sta_to_sta' VALUES ('146', '137', '138')",
"INSERT INTO 'sta_to_sta' VALUES ('147', '138', '139')",
};
for(String o:sqll){//循环所有SQL语句,进行建表和初始化一些数据操作
DB.createTable(o);
}
System.out.println("table");
}catch(Exception e){
e.printStackTrace();
}}}
ShowActivity
package com.example.station;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class ShowActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.show);
TextView show = (TextView) findViewById(R.id.show);
show.setText(getIntent().getStringExtra("answer").trim());
Button back = (Button) findViewById(R.id.btn_back);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
show.xml
listitem.xml