Еще немного закрытия соединения с базой
This commit is contained in:
@ -264,7 +264,7 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb != null) { rdb.close(); }
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
@ -293,19 +293,13 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
if (((selectDB)spiCountry).getValue() != null && !((selectDB)spiCountry).getValue().equals("")) {
|
||||
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";
|
||||
SQLiteDatabase rdb=null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery(sql, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
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 cursor = dboh.getReadableDatabase().rawQuery(sql, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
dboh.close();
|
||||
}
|
||||
}
|
||||
@ -340,7 +334,8 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
// @Override
|
||||
// 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));
|
||||
//
|
||||
// //Теперь выбираем время
|
||||
@ -376,7 +371,8 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
//
|
||||
// if (!LocustActivity.this.edtDate.getText().toString().equals("")) {
|
||||
// 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 {
|
||||
// date = format.parse(LocustActivity.this.edtDate.getText().toString());
|
||||
// } catch (ParseException e) {
|
||||
@ -434,14 +430,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiBioBiotope).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
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);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiBioBiotope).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
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);
|
||||
if (cursor.moveToFirst()) {
|
||||
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();
|
||||
|
||||
spiBioGreenery = findViewById(R.id.spiBioGreenery); // Растительность
|
||||
|
||||
Reference in New Issue
Block a user