Can someone please explain Cursor in android? -


Can some one interpret how the cursor actually works? Or the flow of the following part of the code? I know this sub-activity that is and all, but I did not understand how the cursor is actually works

  Last Uri data = Uri.parse. ("Content: // contact / people /"); Last cursor c = managed query (data, empty, empty, empty, empty); String [] = new string [] {People.NAME}; Int for [] = new int [] {R.id.itemTextView}; SimpleCursorAdapter adapter = new SimpleCursorAdapter (for it, R.layout.listitemlayout, C, for); ListView lv = (ListView) findViewById (R.id.contactListView); Lv.setAdapter (adapter); lv.setOnItemClickListener (New OnItemClickListener () {public void onItemClick (AdapterView & LT ;? & gt; parent, and see, int position, long id) {c.moveToPosition (POS) Integer rowId = c.getInt ( c.getColumnIndexOrThrow ( "_ id")); Uri Autuarai = Urikparsi (data. to string () + row id); Autdeta intent = new Intent (); Autdeta Ksetdeta (Autyuri); set Reslt (activity. Arisyueldio , Outdata); finish ();}});  

Thanks.

cursor is like an index / pointer like a $ Race mysql_query in (PHP from database resources ())

When you run

  managedQuery (data, null, null, null, null);  

contact query, it is a pointer to the record results of a cursor

Then you create an adapter from the cursor. The results taken from the adapter source are an object-level presentation, currently the cursor is, records aka from the database. (Sounds like an array of smart templates in PHP for the adapter, the array adapter)

setOnItemClickListener is easy to understand that you should be aware of the event-based programming.


Comments