我无法打开数据库并对其进行查询

I am not able to open database and query on it

强文本

我无法打开数据库并对其进行查询。我想访问使用意图值从不同的 java 文件传递​​的 table 行。请帮忙 !

import java.io.File;
import java.util.ArrayList;
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

public class Finish_kitchen extends Activity {
    GridView gridView;
    private imageAdapter imageAdapter;
    private SQLiteDatabase db;
    private static String DB_Path = "/mnt/sdcard/Kitchen_Data.db";
    private Cursor c;
    private String path;
    private ListView listView1;
    private ArrayList<String> Steps;
    private ArrayList<String> Image_path;
    private ArrayList<String> Audio_path;
    private int count;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.finish_kit);
        listView1 = (ListView) findViewById(R.id.listView1);
        Steps = new ArrayList<String>();
        Image_path = new ArrayList<String>();
        Audio_path = new ArrayList<String>();
        path = getIntent().getStringExtra("path");
        db = SQLiteDatabase.openDatabase(DB_Path, null, SQLiteDatabase.OPEN_READWRITE);
        c = db.query(path, null, null, null, null, null, null);
        c.moveToFirst();
        Steps.add(c.getString(1));
        Toast.makeText(getApplicationContext(), "heyaa gotcha", Toast.LENGTH_LONG).show();
    }
}

Logcat

04-04 11:50:02.411: D/PackageItemInfo(26824): loadIcon(cached)name=org.example.beproj.MainActivity 04-04 11:50:49.752: D/skia(26824): new locale 04-04 11:50:54.116: W/IInputConnectionWrapper(26824): showStatusIcon on inactive InputConnection 04-04 11:52:06.674: W/MediaRecorder(26824): mediarecorder went away with unhandled events 04-04 11:52:12.390: E/SQLiteLog(26824): (1) near "/": syntax error 04-04 11:52:12.390: D/AndroidRuntime(26824): Shutting down VM 04-04 11:52:12.390: W/dalvikvm(26824): threadid=1: thread exiting with uncaught exception (group=0x41b11ae0) 04-04 11:52:12.400: E/AndroidRuntime(26824): FATAL EXCEPTION: main 04-04 11:52:12.400: E/AndroidRuntime(26824): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.beproj/org.example.beproj.Finish_kitchen}: android.database.sqlite.SQLiteException: near "/": syntax error (code 1): , while compiling: SELECT * FROM /storage/sdcard0/Kitchen/mnvx 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2186) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2236) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.ActivityThread.access0(ActivityThread.java:145) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.os.Handler.dispatchMessage(Handler.java:99) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.os.Looper.loop(Looper.java:137) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.ActivityThread.main(ActivityThread.java:5099) 04-04 11:52:12.400: E/AndroidRuntime(26824): at java.lang.reflect.Method.invokeNative(Native Method) 04-04 11:52:12.400: E/AndroidRuntime(26824): at java.lang.reflect.Method.invoke(Method.java:511) 04-04 11:52:12.400: E/AndroidRuntime(26824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803) 04-04 11:52:12.400: E/AndroidRuntime(26824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570) 04-04 11:52:12.400: E/AndroidRuntime(26824): at dalvik.system.NativeStart.main(Native Method) 04-04 11:52:12.400: E/AndroidRuntime(26824): Caused by: android.database.sqlite.SQLiteException: near "/": syntax error (code 1): , while compiling: SELECT * FROM /storage/sdcard0/Kitchen/mnvx 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:888) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:499) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1161) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1032) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1200) 04-04 11:52:12.400: E/AndroidRuntime(26824): at org.example.beproj.Finish_kitchen.onCreate(Finish_kitchen.java:50) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.Activity.performCreate(Activity.java:5117) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 04-04 11:52:12.400: E/AndroidRuntime(26824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150) 04-04 11:52:12.400: E/AndroidRuntime(26824): ... 11 more 04-04 11:52:14.922: I/Process(26824): Sending signal. PID: 26824 SIG: 9

c = db.query(path, null, null, null, null, null, null);

第一个参数应该是您的 table 姓名。但是你给的是文件路径。

这里是报错信息-

11:52:12.400: E/AndroidRuntime(26824): Caused by: android.database.sqlite.SQLiteException: near "/": syntax error (code 1): , while compiling: SELECT * FROM /storage/sdcard0/Kitchen/mnvx