我有一个名为HOSPITALS.db的数据库,有97个条目和8个列。 I tried following this。
但它产生了错误
java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.mariel.paths / com.example.mariel.paths.MainActivity}:android.database.sqlite.SQLiteException:no such table:hospitalList(code 1 ):,同时编译:SELECT * FROM hospitalList
TableB
Hospitals.java
dbHelper = new DataBaseHelper(this);
dbHelper.openDataBase();
hosp = new Hospitals();
hosp = dbHelper.Get_ContactDetails();
ArrayList<OverlayItem> anotherOverlayItemArray = new ArrayList<>();
for (int i = 0; i < hosp.getHospName().size(); i++){
anotherOverlayItemArray.add(new OverlayItem("Road", "Nodes", new GeoPoint(hosp.getLatitude().get(i), hosp.getLongitude().get(i))));
}
ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay
= new ItemizedIconOverlay<>(
this, anotherOverlayItemArray, null);
map.getOverlays().add(anotherItemizedIconOverlay);
dbHelper.close();
DataBaseHelper.java
public class Hospitals {
public List<String> hosp_name = new ArrayList<>();
public List<Double> longitude = new ArrayList<>();
public List<Double> latitude = new ArrayList<>();
public List<String> getHospName() {
return hosp_name;
}
public void setName(List<String> hosp_name) {
this.hosp_name = hosp_name;
}
public List<Double> getLatitude() {
return latitude;
}
public void setLatitude(List<Double> latitude){
this.latitude = latitude;
}
public List<Double> getLongitude() {
return longitude;
}
public void setLongitude() {
this.longitude = longitude;
}
// constructor
public Hospitals (List<String> hosp_name, List<Double> latitude, List<Double> longitude){
this.hosp_name = hosp_name;
this.latitude = latitude;
this.longitude = longitude;
}
public Hospitals (){
}
}