The implementation seems to be, as always, typical, but the cursor stubbornly does not want to find data on the registration of a click on an element. It passes the correct position (from 0 and up to the list items) and then simply finds 0 items. Base initialized and correctly filled. Tell me, what could be the error?

listViewPasswords.setOnItemClickListener(new AdapterView.OnItemClickListener() { Bundle tempBundle = new Bundle(); @Override public void onItemClick(AdapterView<?> listView, View v, int position, long id) { //Π±Ρ€Π°Ρ‚ΡŒ Position для ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ†ΠΈΠΈ Π½ΠΎΠΌΠ΅Ρ€Π° пароля! DialogFragment dialogShowPass = new DetailedPassFragment(); //ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ Ρ„Ρ€Π°Π³ΠΌΠ΅Π½Ρ‚ ShowPass PasswordDatabaseHelper helper = new PasswordDatabaseHelper(MainActivity.this); SQLiteDatabase dbShowPass = helper.getReadableDatabase(); Cursor cursorShowPass = dbShowPass.query("DATAPASS", new String[]{"SITE", "PASS", "INFO"}, "_id = ?", new String[]{Integer.toString(position)}, null, null, null); if(cursorShowPass.moveToFirst()) { tempBundle.putString("site", cursorShowPass.getString(0)); tempBundle.putString("pass", cursorShowPass.getString(1)); tempBundle.putString("info", cursorShowPass.getString(2)); dialogShowPass.setArguments(tempBundle); dialogShowPass.show(getFragmentManager(), "editPass"); } else { Toast.makeText(MainActivity.this, "Data not send into Bundle"+" "+cursorShowPass.getCount(), Toast.LENGTH_SHORT).show(); } } }); 
  • You have hardcoded query parameters. There may be typos. You did not recreate the database after changing the structure. You have instant wounds enabled and changes in the code are not poured onto the device or for many other reasons - YuriySPb ♦
  • Parameters rendered in constants on writing and reading. What kind of re-creation because of the structure in question? After adding elements, they appear in the list through the SimpleCursorAdapter (and this cursor works), and everything goes fine until it reaches this problem cursor. Instant wounds disabled. All the same, nothing has changed - GeniusRUS
  • Here, try to see your database here. There you can immediately sql query to perform that you need github.com/pavel163/ProbeTools - pavel163
  • one
    Are you sure that _id matches the position in the list? - Eugene Krivenja
  • Eugene Krivenja You are right. It is necessary to look at the long id, although it gives out strange values, but it gives normal links. And made the implementation of the search in the main thread. I understand, not a very idea, but if you give an idea how to implement the transfer of the results of the asynchronous flow to the rendered Dialog, I will be very grateful - GeniusRUS

0