Have set up a storage adapter (Contextual) for help creating and managing a single database and table. Trying to access the table from a new thread for reading records and transmitting them via HTTP in the background. Other access to the database is activity based and insert only. Although the data is small the thread may run a few seconds based on the number of possible records. There is not need to communicate back to the UI.
StorageAdapter Class (SQL Lite Set up)
private static SQLiteDatabase db;
private Context context;
private StorageOpenHelper dbHelper;
public StorageAdapter(Context _context) {
this.context = _context;
dbHelper = new StorageOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
}
The error message from the thread below is: “The constructor StorageAdapter(Worker) is undefined”
Here is the thread:
public void run () {
// Does Storage Adapter need to be runnable
// Read DB ID's of committed (1) records into array
**StorageAdapter storageAdapter = new StorageAdapter(this);**
storageAdapter.open();
cursor = storageAdapter.queueCommID();
int i = 0;
int currcnt = cursor.getCount();
if (cursor.getPosition() == -1) cursor.moveToFirst();
while (i < currcnt) {
// Send single record to server
sendrec(cursor);
i=i+1;
cursor.moveToNext();
}
storageAdapter.close();
stop();
};
Sure hope I did not confuse everyone. Been chasing my tail for a few days and I am very confused.Thank yo for any assistance.
seems like you are creating your StorageAdapter instance from within a Worker instance. that means the this references a Worker instead of a Context. in case your Worker is an anonymous class, you could use something like MyActivity.this instead of just this.