Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android AVD中未加载SQLite数据库_Android_Sqlite_Intellij Idea - Fatal编程技术网

android AVD中未加载SQLite数据库

android AVD中未加载SQLite数据库,android,sqlite,intellij-idea,Android,Sqlite,Intellij Idea,我已经运行了这段代码,但是当我想使用db时,AVD不起作用 我已将.db文件复制到资产中!但是我不知道为什么不行! 它说:不幸的是,节目停止了 有人能帮忙吗 public class MyActivity extends Activity { Button run; EditText ed; TextView v; SQLiteDatabase db; @Over ride public v

我已经运行了这段代码,但是当我想使用db时,AVD不起作用 我已将.db文件复制到资产中!但是我不知道为什么不行! 它说:不幸的是,节目停止了 有人能帮忙吗

       public class MyActivity extends Activity {
        Button run;
        EditText ed;
        TextView v;
        SQLiteDatabase db;

        @Over

ride
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        run = (Button) findViewById(R.id.search);
        ed = (EditText) findViewById(R.id.word);
        v = (TextView) findViewById(R.id.res);

        try {
            String path="/data/data/"+getPackageName()+"/databases/dic.db";
            v.append("output file created ! \n");
            File dbfile= new File(path);
            if(!dbfile.exists())
            {   try
                {
                    v.append("file not exist !  \n");
                    InputStream in=getAssets().open("dic.db");
                    v.append("input file opend \n");
                    OutputStream out = new FileOutputStream(dbfile);
                    byte[] buffer = new byte[1024];
                    int length;

                    while ((length = in.read(buffer)) > 0)
                        out.write(buffer, 0, length);

                    out.flush();
                    out.close();
                    in.close();
                    v.append("db copied!");
                }
                catch (IOException e)
                {
                    v.append("ERR:"+e.getMessage());
                }
            }
        }
        catch (SQLException e)
        {
            v.append("ERR:"+e.getMessage());
        }

        run.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                v.append(ed.getText()+":");
                try
                {
                    db=openOrCreateDatabase("dic.db",MODE_PRIVATE,null);
                    v.append("db opend \n");

                    Cursor c;
                    c = db.rawQuery("SELECT * FROM words WHERE en='"+ed.getText()+"';",null);
                    v.append(c.getString(1));

                }
                catch (SQLException e)
                {
                    v.append("ERR:"+e.getMessage());
                }
            }
        } );

    }
}

干杯。

有异常抛出吗?没有异常!!!只有当我点击按钮时程序才停止!您可以在ur LogCat中看到。如果强制关闭,则一定会出现异常。Eclipse-->单击左下角(显示视图为快速视图)-->单击LogCat-->查看错误-->并将其粘贴到此处。我正在使用intellij IDEA:((