Android SQLITE retrieving data error. :     i want to save some data on **SQLITE** Database.But this code seems doesnt work.
    
    *Here is my Database Helper code:-*
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    
    import java.util.ArrayList;
    
    /**
     * Created by ProgrammingKnowledge on 4/3/2015.
     */
    public class saveClients extends SQLiteOpenHelper {
        public static final String DATABASE_NAME = "client.db";
        public static final String TABLE_NAME = "Client_Info";
        public  static  final int ver=1;
        public static int i=0;
        public static final String COL_1 = "ID";
        public static final String COL_2 = "NAME";
        public static final String COL_3 = "Email";
        public static final String COL_4 = "Balance";
    
        public saveClients(Context context) {
            super(context, DATABASE_NAME, null, ver);
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL("create table " + TABLE_NAME +" (ID INTEGER,NAME TEXT,Email TEXT,Balance TEXT)");
        }
    
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
            onCreate(db);
        }
    
        public boolean insertData(String ID,String Fname,String Email,String Balance) {
            SQLiteDatabase db = this.getWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(COL_1,ID);
            contentValues.put(COL_2,Fname);
            contentValues.put(COL_3,Email);
            contentValues.put(COL_4,Balance);
            long result = db.insert(TABLE_NAME,null ,contentValues);
            if(result == -1)
                return false;
            else
                return true;
        }
    
    
      public boolean checkForTables(){
          SQLiteDatabase db = this.getWritableDatabase();
          boolean hasTables = false;
          db = this.getWritableDatabase();
          Cursor cursor = db.rawQuery("SELECT * FROM " +TABLE_NAME, null);
    
          if(cursor != null && cursor.getCount() > 0){
              hasTables=true;
              cursor.close();
          }
    
          return hasTables;
      }
    
    
        public void deleteData () {
            SQLiteDatabase db = this.getWritableDatabase();
             db.execSQL("delete * from"+ TABLE_NAME);
        }
    
        public ArrayList<String> getAllData() {
            ArrayList<String> list=new ArrayList<>();
            String QUERY = "SELECT  * FROM " + TABLE_NAME;
    
            SQLiteDatabase db = this.getWritableDatabase();
    
            Cursor cursor = db.rawQuery(QUERY, null);
            if(cursor!=null) {
                while (cursor.moveToNext()) {
                    list.add(cursor.getString(i));
                    i++;
    
                }
            }else{
                list.add("X");
            }
            return list;
        }
    
    
    }
    
     

And here is my **client Activity code**: Below:

   

     import android.content.Intent;
        import android.os.Bundle;
        import android.support.v7.app.AppCompatActivity;
        import android.view.View;
        import android.widget.Button;
        import android.widget.TextView;
        import android.widget.Toast;
        
        import com.sdsmdg.tastytoast.TastyToast;
        
        import java.util.ArrayList;
        
        public class clientView extends AppCompatActivity {
            TextView Fname, Email, ID, Balance;
            final saveClients obj = new saveClients(this);
        
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_client_view);
                if (obj.checkForTables() == false) {
                    String getingid = getIntent().getStringExtra("ID");
                    String getingname = (getIntent().getStringExtra("Fname"));
                    String getinmail = (getIntent().getStringExtra("Email"));
                    String getingBalan = (getIntent().getStringExtra("Balance"));
                    obj.insertData(getingid, getingname, getinmail, getingBalan);
                    TastyToast.makeText(clientView.this, "Logged In", TastyToast.SUCCESS, TastyToast.LENGTH_LONG).show();
                }
        
        
                ArrayList<String> data = new ArrayList<>(obj.getAllData());
                // ---------------------------------------------------------------------------------------------
                // ---------------------------------------------------------------------------------------------
                if(data.get(0).equals("X")){
                    Toast.makeText(this, "Database Error", Toast.LENGTH_SHORT).show();
                }
                Fname = (TextView) findViewById(R.id.Fname);
                Email = (TextView) findViewById(R.id.Email);
                ID = (TextView) findViewById(R.id.ID);
                Balance = (TextView) findViewById(R.id.Balance);
                Button button = (Button) findViewById(R.id.lgout);
                ID.setText(data.get(0));
                Fname.setText(data.get(1));
                ID.setText(data.get(2));
                Balance.setText(data.get(3));
        
                button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Fname.setText("");
                        Email.setText("");
                        ID.setText("");
                        Balance.setText("");
                        obj.deleteData();
                        Intent pushback = new Intent(clientView.this, MainActivity.class);
                        startActivity(pushback);
                    }
                });
        
                // ---------------------------------------------------------------------------------------------
                // ---------------------------------------------------------------------------------------------
        
            }
        }



I want to retrive all data by **getAlldata()** method.But it keeps crashing.And one more question is can use sql query to retrive any data from SQLITE database.Then please share how can i do it.