cursor

How to update listview whose data was queried from database through SimpleCursorAdapter?

时光怂恿深爱的人放手 提交于 2019-12-01 01:39:29
I want to show the items queried from database in the listview with SimpleCursorAdapter. For example, there may be 20,000 items in the database. I want to just load 100 items(_id : 1-100) queried instead of load all items, when scrolling in the end of listview, load another 100 items(_id : 101-200) queried, how to achieve it? Any suggestion is welcome, thanks. Relative codes are as follows: protected void onCreate(Bundle savedInstanceState) { mCursor = managedQuery(CONTENT_URI, PROJECTION, null, null, "_id DESC"); mAdapter = new SimpleCursorAdapter(this,R.layout.list_content, mCursor, keys,

Passing a cursor to an activity?

自闭症网瘾萝莉.ら 提交于 2019-12-01 01:23:05
Is this possible? I am trying to open a SQLite database cursor in one activity, and pass it to another activity. I personally don't know of any simple ways to do this. It might be easier just to make the query again in the destination activity. Another way to do this which might be easier is to create an Application class for your app. This is guaranteed to be created only once, and exists for the lifetime of your app. Among other things, it can provide a "data hub" capability for your app so different Activities can share data easily. So, for your cursor, you'd simply use a member variable of

TSQL Cursor how to check if already declared and thus deallocate

笑着哭i 提交于 2019-12-01 01:20:06
问题 How can I make sure that I deallocate a cursor if it already exists before I try and open it again? For a table I can use something like: if exists (select top 1 from tempdb.sys.tables where name = '##tmpTable') drop table ##tmpTable; ... then I can recreate my ##tmpTable But I can't work out how to do it for a cursor like -- First clean up if already exists.. ..... <----- what goes here??? -- Declare and use a cursor DECLARE someCursorName CURSOR FOR select something from somewhere FOR READ

20191010

梦想与她 提交于 2019-12-01 01:19:08
caption 标题 field 字段 policy 规则 emergency 紧急 程序中添加 串口模块: qt += serialport 命名空间宏定义: QT_BEGIN_NAMESPACE QT_END_NAMESPACE QT_USE_NAMESPACE //Returns a list of available serial ports on the system. const auto infos = QSerialPortInfo::availablePorts(); obj->setFocus(); 设置默认焦点 QMutex 提供线程之间的访问序列化。 如果另一个线程已锁定互斥锁,则此调用将被阻止,直到该线程已将其解锁。 QWaitCondition 为线程同步提供了条件变量 QWaitCondition.wait() 释放lockedmutex并等待等待条件。 forever { mutex.lock(); keypressed.waited(&mutex); do_something(); mutex.unlock(); } QTextCodec 提供文本间的编码转换 verify 验证 设置鼠标: QCursor cursor; QPixmap pixmap("mm.png"); cursor = QCursor(pixmap,-1,-1);

How to use CursorWrapper to filter Cursor rows

回眸只為那壹抹淺笑 提交于 2019-12-01 00:48:41
I want to filter out some rows returned by a Cursor based on a specific condition (which I want to test after receiving the rows from the database, because it's not easy to add it to a WHERE clause in the SQL query). I found the following related questions: Filter rows from Cursor so they don't show up in ListView , Filtering a cursor the right way? , and How to hide specific rows of a Cursor in android . I want to implement exactly what those questions are asking. While the answers to those questions show how to implement a CursorWrapper (which I have done), I don't know how to then link that

Android: Content resolver query returning 0 rows when it ought not to

蹲街弑〆低调 提交于 2019-12-01 00:46:31
Cursor cursor = resolver.query( Data.CONTENT_URI, DataQuery.PROJECTION, DataQuery.SELECTION, new String[] {String.valueOf(rawContactId)}, null); With PROJECTION being: public static final String[] PROJECTION = new String[] { Data._ID, Data.MIMETYPE, Data.DATA1, Data.DATA2, Data.DATA3}; and SELECTION being: public static final String SELECTION = Data.RAW_CONTACT_ID + "=?"; The rawcontactId does return values, I've made logs to check. To give it some context I'm working with Account sync. The goal here is for it to find the data columns for existing contacts and writing over them with any new

Get SMS Details From its ID Android

谁说我不能喝 提交于 2019-12-01 00:45:14
I want to get Details of SMS(Number, Text Body, Time of coming); And i only know the id of sms. Can i query to "content://sms" with this id and get details? At the moment i can make a loop and query for every message and get details. But that is not efficient when you have to get single sms details 10 times from 1000 sms..... Hope you understand the problem. Thanx Farhan I figure out my self but took me some time, Following code works for me: Uri myMessage = Uri.parse("content://sms/"); ContentResolver cr = getContentResolver(); Cursor c = cr.query(myMessage, new String[] { "_id", "address",

Cursor Index Out of Bounds Exception

两盒软妹~` 提交于 2019-12-01 00:35:43
In attempting to execute a query on my database, I get this exception. However, the documentation states that the method SQLiteDatabase.query(...) returns, "A Cursor object, which is positioned before the first entry," which I interpret to mean that the Cursor is at the start of the rows returned. If I add the Cursor.moveToFirst() before accessing data in the Cursor, I get no exception. What is going on? Do I need to always call "moveToFirst" before trying to get data? The documentation says this method, "moves the cursor to the first row." Cursor c = db.query(TABLENAME, null, null, null, null

How to clone or freeze an Android database cursor

三世轮回 提交于 2019-12-01 00:28:04
I have a custom cursor adapter, and I would like to pass each 'row' of the cursor back to the application (via a registered callback which is working). I know I could read each of the fields from the cursor and do it manually, but I would simply like to pass a 'frozen clone' of the cursor back. (Reading the fields in the adapter would require me to make several specialised versions of this class.) Ideally I would like to pass back something with the same interface as Cursor, but which couldn't traverse the result set. The queries return fewer than 20 rows, so space is not an issue. M-WaJeEh I

mysql number of records in cursor without iterating?

北城以北 提交于 2019-12-01 00:27:20
问题 I am trying to write mysql procedure for below logic, select id, fullname from users where fullname like concat(lastname, ' ', firstname, ' (' , middlename, '%'); if above query returns 0 records then select id, fullname from users where fullname like concat(lastname, ' ', firstname, '%'); .... few more queries depending upon result, I am trying to write procedure mysql procedure , in that, I am using mysql cursor, DECLARE user_cnt CURSOR FOR select id, fullname from users where fullname like