Remove DeliveryDbAdapter global definition and use

DbAdapter only use when sending message. Si the DB is less often locked
This commit is contained in:
Mathieu Maret 2011-07-29 14:55:17 +02:00
parent 1ddedcc67b
commit 420f1c303b

View File

@ -36,7 +36,6 @@ public class MultiSmsSender extends Activity {
private TextView mEditor; private TextView mEditor;
private CheckBox mDeliveryCheckBox; private CheckBox mDeliveryCheckBox;
private DeliveryDbAdapter mDbHelper;
private ProgressDialog mSendingDialog; private ProgressDialog mSendingDialog;
public static final int ACTIVITY_EDIT = 0; public static final int ACTIVITY_EDIT = 0;
@ -163,8 +162,6 @@ public class MultiSmsSender extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
mDbHelper = new DeliveryDbAdapter(this);
mDbHelper.open();
mAddButton = (Button) findViewById(R.id.contacts); mAddButton = (Button) findViewById(R.id.contacts);
mSend = (Button) findViewById(R.id.send); mSend = (Button) findViewById(R.id.send);
@ -220,6 +217,8 @@ public class MultiSmsSender extends Activity {
} }
public void sendMessage(Handler handler) { public void sendMessage(Handler handler) {
DeliveryDbAdapter mDbHelper = new DeliveryDbAdapter(this);
mDbHelper.open();
SmsManager manager = SmsManager.getDefault(); SmsManager manager = SmsManager.getDefault();
String message = mEditor.getText().toString(); String message = mEditor.getText().toString();
HashMap<String, Long> deliveryIdMap = new HashMap<String, Long>(); HashMap<String, Long> deliveryIdMap = new HashMap<String, Long>();
@ -264,6 +263,7 @@ public class MultiSmsSender extends Activity {
} }
} }
mDbHelper.close();
numbers = new String[size]; numbers = new String[size];
@ -463,7 +463,6 @@ public class MultiSmsSender extends Activity {
protected void onDestroy() { protected void onDestroy() {
appli_running = false; appli_running = false;
mDbHelper.close();
super.onDestroy(); super.onDestroy();
} }
@ -481,4 +480,4 @@ public class MultiSmsSender extends Activity {
} }