已设置存储适配器(上下文)以帮助创建和管理单个数据库和表。尝试从新线程访问表以读取记录并在后台通过 HTTP 传输它们。对数据库的其他访问是基于活动的并且仅插入。尽管数据很小,但线程可能会根据可能的记录数运行几秒钟。无需与 UI 进行通信。
StorageAdapter 类(SQL Lite 设置)
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);
}
以下线程的错误消息是:“构造函数 StorageAdapter(Worker) 未定义”
这是线程:
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();
};
当然希望我没有混淆大家。几天一直在追我的尾巴,我很困惑。谢谢你的帮助。