android - Index 2 requested with size of 2 -


I'm a newbie for Android development and here is my first project in the Gridview database.

I sqlite I am using database db file

this is my code

Please help me !!! !!

  Expands the main activity activity of the public class (overwrite public zeros on SQLiteDatabase mydb; Grid view data; @Create (bundled saved instance) {super. ); SetContentView (R.layout.activity_main); Data = (Gridview) Find VVBIID (RIDGrid View 1); List of & lt; string & gt; Li = New Arreelist & lt; string & gt; () ; ArrayAdapter & LT; String & gt; DataAdapter = New Array Adapter & lt; st Ring & gt; getApplicationContext (), android.R.layout.simple_spinner_dropdown_item, li); dataAdapter.setDropDownViewResource (R.layout.activity_main); try {mydb = openOrCreateDatabase (getString (R.string._sdcard_sales_db), MODE_PRIVATE, null) ; Cursor CR = mydb.rawQuery ("select from users", blank); if (ver! = Tap) {if (cr.moveToFirst) {do {string desc = cr.getString (cr.getColumnIndex ("user "); Li.add (DESC);} while (cr.moveToNext ()); Toast. GetApplicationContext (), CR.getString (cr.getColumnIndex (" user "), toast. LNNHH_LOG). Show (); } Else {toast.makeText (getApplicationContext (), "no data", toast.lNGTH_LONG). Show (); }} Cr.close (); Mydb.close (); } Hold (exception e) {toast. GetApplicationContext, "Error" + E. Gate Message (), Toast. LNNHH_LOG). Show (); Thanks in advance   

  {string del = cr.getstring (cr.getColumnIndex ("user ")); Li.add (DESC); } While (cr.moveToNext ()); Toast. Show text (getApplicationContext (), CR.getString (cr.getColumnIndex ("user"), toast.LnnHH_LOG) Show  

After the do-all loop, the last valid row After the cursor returns a cr number on a line.

Toast where you get getString () to an invalid cursor index , Or change to toast the information that you really want.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -