【问题标题】:Android Studio code doesn't work on Android Version P 9.0Android Studio 代码在 Android P 9.0 上不起作用
【发布时间】:2020-12-05 05:47:13
【问题描述】:

请我的 Android 应用程序在任何 Android 应用程序版本中都能正常工作,但在 android 9.0 上不能工作??在模拟器上从android studio运行代码时没有显示错误,问题是AutoCompleteTextView不起作用,但在其他更高和更低版本上运行良好。我的代码是:

AutoCompleteTextView srch_txt=(AutoCompleteTextView) findViewById(R.id.srch_txt);
        DBConnection db = new DBConnection(this);
        //SQLiteDatabase dbb = db.getWritableDatabase();//connect to MyDB
        SQLiteDatabase dbb = db.getReadableDatabase();//connect to MyDB
        final String [] mydata;
        //Inside the method you've read the cursor, loop through it and add those item to array
        String sql="SELECT * FROM revuesC";
        //execute SQL
        Cursor cr= dbb.rawQuery(sql, null);
        mydata = new String[cr.getCount()];//create array string based on numbers of row
        int i=0;
        while (cr.moveToNext()) {
            mydata[i]= cr.getString(1);
            i++;
        }
        cr.moveToFirst();
        ArrayAdapter<String> adapter = new ArrayAdapter<String>
                (this,android.R.layout.select_dialog_item,mydata);
        //Getting the instance of AutoCompleteTextView
        //AutoCompleteTextView actv =  (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView);
        srch_txt.setThreshold(1);//will start working from first character
        srch_txt.setAdapter(adapter);//setting the adapter data into the AutoCompleteTextView
        cr.close();

> Blockquote

【问题讨论】:

    标签: android sqlite autocompletetextview dbconnection


    【解决方案1】:

    我通过在我的 DBConnectionHelper 中添加此 @override 方法来解决此问题:

    @Override
        public void onOpen(SQLiteDatabase db) {
            super.onOpen(db);
            db.disableWriteAheadLogging();
        }
    

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 2017-08-19
      • 2019-06-28
      • 2018-06-11
      • 2018-03-08
      • 1970-01-01
      • 2021-10-22
      • 2021-08-02
      • 2019-10-17
      相关资源
      最近更新 更多