2017-12-27 13 views
-1

sqlitedatabaseクラスにインポートされていないが、私はSQLiteのデータベースを使用していたアプリケーションに取り組んでいますMySQLiteopenhelperとデータベースクラスが主な活動

主な活動で、それをインポートする方法を、インポートされていません。私はMySQLitedatabaseとopenhelper変数の変数の宣言に誤りがあります。

DatabaseHelper.java

package com.example.scs.scs; 

import android.content.ContentValues; 
import android.content.Context; 
import android.database.Cursor; 
import android.database.sqlite.SQLiteDatabase; 
import android.database.sqlite.SQLiteOpenHelper; 


public class DatabaseHelper extends SQLiteOpenHelper{ 
    private static final int DATABASE_VERSION=1; 
    private static final String DATABASE_NAME="UserRegistration"; 
    private String TABLE_REGDETAIL="UserRegistration"; 
    private String KEY_ID="id"; 
    private String KEY_FIRSTNAME="firstname"; 
    private String KEY_LASTNAME="lastname"; 
    private String KEY_EMAIL="email"; 
    private String KEY_PASSWORD="password"; 
    private String KEY_HINT="hint"; 
    private String KEY_COUNTRY="country"; 
    private String KEY_CONTACTNO="contactno"; 
    public DatabaseHelper(Context context) 
    { 
     super(context,DATABASE_NAME,null,DATABASE_VERSION); 
    } 
    @Override 
    public void onCreate(SQLiteDatabase db) { 
String CREATE_REGDETAIL_TABLE="CREATE TABLE"+TABLE_REGDETAIL+"(" 
     +KEY_ID+"INTEGER,"+KEY_FIRSTNAME+"TEXT,"+KEY_LASTNAME+"TEXT,"+KEY_EMAIL+"TEXT PRIMARY KEY,"+KEY_PASSWORD+"TEXT,"+KEY_HINT+"TEXT,"+KEY_COUNTRY+"TEXT," 
    +KEY_CONTACTNO+"TEXT"+")"; 
    db.execSQL(CREATE_REGDETAIL_TABLE); 
    } 

    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 
     db.execSQL("DROP TABLE IF EXISTS"+TABLE_REGDETAIL); 
     onCreate(db); 

    }} 




MainActivity.java 


package com.example.scs.scs; 

import android.graphics.Typeface; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 

public class Registration extends AppCompatActivity { 
    MySQliteOpenHelper mySqliteOpenHelper; 
    private MySQLiteDatabase database; 
    TextView fname, lname, remail, r_pass, contctnum, r_hint, r_country; //declaring variables for editview 
    Button btnreg; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_registration); 
     DatabaseHelper db = new DatabaseHelper(this); 
     fname = (TextView) findViewById(R.id.edtfrstname); 
     lname = (TextView) findViewById(R.id.edtlastname); 
     remail = (TextView) findViewById(R.id.edtreg_email); 
     r_pass = (TextView) findViewById(R.id.edtreg_pass); 
     contctnum = (TextView) findViewById(R.id.edtcontactnum); 
     r_hint = (TextView) findViewById(R.id.edtpass_hint); 
     r_country = (TextView) findViewById(R.id.edtcountry); 
     btnreg = (Button) findViewById(R.id.btnregister); 
     Typeface myCustomFont = Typeface.createFromAsset(getAssets(), "fonts/Gabriola.ttf"); 
     fname.setTypeface(myCustomFont);//font style of frst name edittext 
     lname.setTypeface(myCustomFont);//font style of last name edittext 
     remail.setTypeface(myCustomFont);//font style of reg email button 
     r_pass.setTypeface(myCustomFont);//font style of reg pass button 
     contctnum.setTypeface(myCustomFont);//font style of contact num 
     r_hint.setTypeface(myCustomFont);//font style of reg hint 
     r_country.setTypeface(myCustomFont);//font style of reg country 
     btnreg.setTypeface(myCustomFont); 

     btnreg = (Button) findViewById(R.id.btnregister); 
     btnreg.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       mySqliteOpenHelper = new MySQLiteOpenHelper(getApplicationContext()); 



      } 
     }); 

    } 
} 

MainActivity.java

package com.example.scs.scs; 

import android.graphics.Typeface; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 

public class Registration extends AppCompatActivity { 
    MySQliteOpenHelper mySqliteOpenHelper; 
    private MySQLiteDatabase database; 
    TextView fname, lname, remail, r_pass, contctnum, r_hint, r_country; //declaring variables for editview 
    Button btnreg; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_registration); 
     DatabaseHelper db = new DatabaseHelper(this); 
     fname = (TextView) findViewById(R.id.edtfrstname); 
     lname = (TextView) findViewById(R.id.edtlastname); 
     remail = (TextView) findViewById(R.id.edtreg_email); 
     r_pass = (TextView) findViewById(R.id.edtreg_pass); 
     contctnum = (TextView) findViewById(R.id.edtcontactnum); 
     r_hint = (TextView) findViewById(R.id.edtpass_hint); 
     r_country = (TextView) findViewById(R.id.edtcountry); 
     btnreg = (Button) findViewById(R.id.btnregister); 
     Typeface myCustomFont = Typeface.createFromAsset(getAssets(), "fonts/Gabriola.ttf"); 
     fname.setTypeface(myCustomFont);//font style of frst name edittext 
     lname.setTypeface(myCustomFont);//font style of last name edittext 
     remail.setTypeface(myCustomFont);//font style of reg email button 
     r_pass.setTypeface(myCustomFont);//font style of reg pass button 
     contctnum.setTypeface(myCustomFont);//font style of contact num 
     r_hint.setTypeface(myCustomFont);//font style of reg hint 
     r_country.setTypeface(myCustomFont);//font style of reg country 
     btnreg.setTypeface(myCustomFont); 

     btnreg = (Button) findViewById(R.id.btnregister); 
     btnreg.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       mySqliteOpenHelper = new MySQLiteOpenHelper(getApplicationContext()); 
       database = mySqliteOpenHelper.getReadable 
      } 
     }); 

    } 
} 

答えて

0

あなたのsqliteオープンヘルパークラス名がDatabaseHelperないMySQliteOpenHelperであるように見えます。

MySQLiteDatabaseは、ほとんど特殊化する必要がないため、SQLiteDatabaseに置き換えることができます。

関連する問題