Read and Write on SQLite Database in Android app_project -


A java.lang.NullPointer error I have Logkat but I do not know why it seems that the error on the second OnClick process Was there anybody could help me ??

  package com.example.cinerodeon; Import com.example.cinemaodeon.Main; Public class increases main activity {Private Database Baseer DatabaseHelper; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.main_layout); Last toast toast = Toast. Maketext (this is, "Now no urent, enter new URI so far!", Toast. LNGGLOG); Last Toast Toast 2 = Toast. Maketext (It's "Now Now Uttech GIA Project !!! !!!", Toast.LangthaLong); Button Find BTNGO = (button) VVBIID (RID.mn_btnentra); btnGO.setOnClickListener (New OnClickListener () {@Override public void onClick (View arg0) {SQLiteDatabase db = DatabaseHelper.getReadableDatabase (); String [] columns = { "_id_user"}; cursor = db.query ( "them"; string [] results = new string [] {}; int count = cursor.getCount (); while (Karsrkmovteonakst ()) {result [count] = cursor GetString (0); count = count + 1;} EditText editusername = (EditText) findViewById (R.id.main_editusername) ;. final string username = editusername.getText () toString (); (I Int = 0; i & lt; count; i ++) {if ( User name == results [count]) {intent openProgrammazione = new Intent (Main. This, Programmazione.class); startActivity (openProgrammazione);}} toast.show ();}}); Find button Bitianaraji = (Button) Viviaibiaidi (Araidikman_bitianagristra); btnReg.setOnClickListener (new OnClickListener () { 

it's OnClick process down error, although to much, perhaps there databaseHelper

the definition of @Override Public Zero onClick (see arg0) {SQLiteDatabase db = DatabaseHelper.getReadableDatabase (); String [] column = {"_id_user"}; Cursor cursor = db.query ("those", column, null, null, null, null, null); String [] Results = New String [] {}; Integer number = cursor.getCount (); While (cursor.moveToNext ()) {Results [count] = cursor.getString (0); Count = count + 1;} EditText editusername = (EditText) findViewById (R.id.main_editusername_registra) ;. Last String Username = editusername.getText () toString (); (Int i = 0; i & lt; count; i ++) {if (user name == result [count]) {toast2. Show (); }} SQLiteDatabaseDBW = DatabaseHaller.GetVetadatabase (); Material values ​​= new material value (); Values.put ("_ id_user", user name); @SuppressWarnings ("unused") long id = dbW.insert ("user", zero, value); Intention openProgrammazione = new intent (main. This, Programmazione.class); StartActivity (openProgrammazione); }}); }

You have started DatabaseHelper DatabaseHelper .

Try starting it

Example: Database Database Database Helper = New DatabaseHelper ();


Comments