Еще немного закрытия соединения с базой
This commit is contained in:
@ -264,7 +264,7 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}finally{
|
}finally{
|
||||||
if(rdb != null) { rdb.close(); }
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
@ -293,19 +293,13 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
if (((selectDB)spiCountry).getValue() != null && !((selectDB)spiCountry).getValue().equals("")) {
|
if (((selectDB)spiCountry).getValue() != null && !((selectDB)spiCountry).getValue().equals("")) {
|
||||||
DbOpenHelper dboh = new DbOpenHelper(LocustActivity.this);
|
DbOpenHelper dboh = new DbOpenHelper(LocustActivity.this);
|
||||||
String sql = "select id, name, lon_min from countriesregions where del=0 and country_id=" + ((selectDB)spiCountry).getValue() + " order by name";
|
String sql = "select id, name, lon_min from countriesregions where del=0 and country_id=" + ((selectDB)spiCountry).getValue() + " order by name";
|
||||||
SQLiteDatabase rdb=null;
|
Cursor cursor = dboh.getReadableDatabase().rawQuery(sql, null);
|
||||||
try {
|
if (cursor.moveToFirst()) {
|
||||||
rdb = dboh.getReadableDatabase();
|
do {
|
||||||
Cursor cursor = rdb.rawQuery(sql, null);
|
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
if (cursor.moveToFirst()) {
|
} while (cursor.moveToNext());
|
||||||
do {
|
|
||||||
((selectDB) spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
}finally{
|
|
||||||
if(rdb!=null) { rdb.close();}
|
|
||||||
}
|
}
|
||||||
|
cursor.close();
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,7 +334,8 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
// @Override
|
// @Override
|
||||||
// public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
// public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
||||||
//
|
//
|
||||||
// //SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
|
// //SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||||
|
// //format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
// //LocustActivity.this.edtDate.setText(format.format(curDateTime));
|
// //LocustActivity.this.edtDate.setText(format.format(curDateTime));
|
||||||
//
|
//
|
||||||
// //Теперь выбираем время
|
// //Теперь выбираем время
|
||||||
@ -376,7 +371,8 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
//
|
//
|
||||||
// if (!LocustActivity.this.edtDate.getText().toString().equals("")) {
|
// if (!LocustActivity.this.edtDate.getText().toString().equals("")) {
|
||||||
// Date date = null;
|
// Date date = null;
|
||||||
// SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
|
// SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||||
|
// //format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
// try {
|
// try {
|
||||||
// date = format.parse(LocustActivity.this.edtDate.getText().toString());
|
// date = format.parse(LocustActivity.this.edtDate.getText().toString());
|
||||||
// } catch (ParseException e) {
|
// } catch (ParseException e) {
|
||||||
@ -434,14 +430,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
((selectDB)spiBioBiotope).addField("", "");
|
((selectDB)spiBioBiotope).addField("", "");
|
||||||
// Выбираем страны и заполняем поля
|
// Выбираем страны и заполняем поля
|
||||||
dboh = new DbOpenHelper(this);
|
dboh = new DbOpenHelper(this);
|
||||||
|
SQLiteDatabase rdb = null;
|
||||||
cursor = dboh.getReadableDatabase().rawQuery("select b.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = b.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),b.name) name from list_biotope b where b.del=0 order by b.name", null);
|
try {
|
||||||
if (cursor.moveToFirst()) {
|
rdb = dboh.getReadableDatabase();
|
||||||
do {
|
cursor = rdb.rawQuery("select b.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = b.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),b.name) name from list_biotope b where b.del=0 order by b.name", null);
|
||||||
((selectDB)spiBioBiotope).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
if (cursor.moveToFirst()) {
|
||||||
} while (cursor.moveToNext());
|
do {
|
||||||
|
((selectDB)spiBioBiotope).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
spiBioGreenery = findViewById(R.id.spiBioGreenery); // Растительность
|
spiBioGreenery = findViewById(R.id.spiBioGreenery); // Растительность
|
||||||
|
|||||||
Reference in New Issue
Block a user