SQLiteLog:(1)没有这样的表:系列

时间:2017-03-19 07:36:50

标签: android sqlite android-sqlite sqliteopenhelper

我在我的数据库中更改了某些内容,因此我增加了我的版本。但是,这造成了错误。为了解决这个问题,我卸载了应用程序希望它能够正常工作。但是,我得到的不是这样的表。

这里附有我的数据库助手和系列类的一些代码。

SQLiteOpenHelper类:

var ref: FIRDatabaseReference!
let uid = FIRAuth.auth()?.currentUser?.uid
let activityIndicator = UIActivityIndicatorView()

override func viewDidLoad() {
     super.viewDidLoad()
     self.ref = FIRDatabase.database().reference().child(self.uid!)
}

override func viewWillDisappear(animated: Bool) {
     super.viewWillDisappear(animated)
     NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(fetchSomeValueFromFBThenUpdateAndResendAnotherValue), name: "FbFetchAndSend", object: nil)
}

@IBAction func buttonPressed(sender: UIButton) {
    activityIndicator.startAnimating()
    levelTwoRef //send levelTwo data to FB run 1st callback
         scoreRef   //send score data to FB run 2nd callback
            powerRef //send power data to FB run 3rd  callback
               lifeRef //send life data to FB run Last callback for dispatch_async...

                   dispatch_async(dispatch_get_main_queue()){
                      activityIndicator.stopAnimating()
                      performSegueWithIdentifier....
                      //Notifier fires after performSegue???
                      NSNotificationCenter.defaultCenter().postNotificationName("FbFetchAndSend", object: nil)
                  }
 }

func fetchSomeValueFromFBThenUpdateAndResendAnotherValue(){

    let paymentRef = ref.child("paymentNode")
    paymentRef?.observeSingleEventOfType(.Value, withBlock: {
       (snapshot) in
       if snapshot.exists(){
           if let dict = snapshot.value as? [String:AnyObject]{
           let paymentAmount = dict["paymentAmount"] as? String

           let updatePayment = [String:AnyObject]()
           updatePayment.updateValue(paymentAmount, forKey: "paymentMade")

           let updateRef = self.ref.child("updatedNode")
           updateRef?.updateChildValues(updatePayments)
}

系列课程:

public static final String SCHEMA = "LIFE.db";
public static final int VERSION = 5;

public DatabaseHelperS(Context context) { super(context, SCHEMA, null, VERSION); }

@Override
public void onCreate(SQLiteDatabase db) {
    //CREATE TABLE series ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, description text not null, episodes integer not null, image integer not null, category text not null);
    String sql = "CREATE TABLE " + Series.TABLE + " ( "
            + Series.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + Series.COLUMN_TITLE + " TEXT NOT NULL, "
            + Series.COLUMN_DESCRIPTION + " TEXT NOT NULL, "
            + Series.COLUMN_EPISODES + " INTEGER NOT NULL, "
            + Series.COLUMN_IMAGE + " INTEGER NOT NULL, "
            + Series.COLUMN_CATEGORY + " TEXT NOT NULL);";
    db.execSQL(sql);

}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
    String sql = "DROP TABLE IF EXISTS " + Series.TABLE;
    db.execSQL(sql);
    onCreate(db);
}
public Cursor getAllSeries(){
    SQLiteDatabase db = getReadableDatabase();

    return db.query(Series.TABLE,
            null, // *
            null, // where clause
            null, // where args
            null, // group by
            null, // having
            null  // order by
    );
}

Android监视器logcat:

public static final String TABLE = "series";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_TITLE = "title";
public static final String COLUMN_DESCRIPTION = "description";
public static final String COLUMN_IMAGE = "imagepath";
//public static final String COLUMN_GENRE = "genre";
public static final String COLUMN_EPISODES = "episodes";
public static final String COLUMN_CATEGORY = "category";

我尝试了很多改变数据库名称,更改表名,升级版本等的东西。但它都没有奏效。

使用该代码的行:

03-19 15:31:18.608 4810-4810/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: ph.edu.mobapde.machineproject4, PID: 4810
                                             android.database.sqlite.SQLiteException: no such table: series (code 1): , while compiling: SELECT * FROM series
                                                 at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                 at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:893)
                                                 at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:504)
                                                 at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
                                                 at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                                                 at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
                                                 at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
                                                 at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1426)
                                                 at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1273)
                                                 at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1144)
                                                 at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1312)
                                                 at ph.edu.mobapde.machineproject4.db.DatabaseHelperS.getAllSeries(DatabaseHelperS.java:72)
                                                 at ph.edu.mobapde.machineproject4.Tab.SeriesTab.init(SeriesTab.java:47)
                                                 at ph.edu.mobapde.machineproject4.Tab.SeriesTab.onCreateView(SeriesTab.java:38)
                                                 at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
                                                 at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
                                                 at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
                                                 at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
                                                 at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
                                                 at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
                                                 at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
                                                 at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
                                                 at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1979)
                                                 at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:626)
                                                 at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
                                                 at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
                                                 at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
                                                 at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
                                                 at android.view.View.measure(View.java:18911)
                                                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5995)
                                                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                 at android.view.View.measure(View.java:18911)
                                                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5995)
                                                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                 at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
                                                 at android.view.View.measure(View.java:18911)
                                                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5995)
                                                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                 at android.view.View.measure(View.java:18911)
                                                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5995)
                                                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                 at android.view.View.measure(View.java:18911)
                                                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5995)
                                                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                 at android.view.View.measure(View.java:18911)
                                                at android.view.ViewGroup.measu

0 个答案:

没有答案