我编写了用于将数据存储到 SQLITE 数据库中的 java 插件,但此连接 url 显示错误
是否需要任何权限?
package com.tricedesigns;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.cordova.CordovaWebViewClient;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.sqlite.SQLite;
import com.sun.java.swing.plaf.windows.resources.windows;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
import android.view.Window;
public class HelloPlugin extends Plugin {
public static final String NATIVE_ACTION_STRING="nativeAction";
public static final String SUCCESS_PARAMETER="laxman";
SQLiteDatabase myDb = null;
@Override
public PluginResult execute(String action, JSONArray data, String callbackId) {
Log.d("HelloPlugin", "Hello, this is a native function called from PhoneGap/Cordova!");
//only perform the action if it is the one that should be invoked
if (NATIVE_ACTION_STRING.equals(action)) {
String resultType = null;
try {
resultType = data.getString(0);
Connection connection = null;
ResultSet resultSet = null;
Statement statement = null;
try {
Class.forName("org.sqlite.JDBC");
// webView.loadUrl("jdbc:sqlite:tempdb.db");
connection = DriverManager
.getConnection("jdbc:sqlite:tempdb.db");
statement = connection.createStatement();
System.out.println("dddddddddddddddddddddd");
resultSet = statement
.executeQuery("SELECT name FROM temp");
while (resultSet.next()) {
System.out.println(" NAME:"
+ resultSet.getString("name"));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
resultSet.close();
statement.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("result typeeeeeeeee"+data.getString(0));
}
catch (Exception ex) {
Log.d("HelloPlugin", ex.toString());
}
if (resultType.equals(SUCCESS_PARAMETER)) {
try {
return new PluginResult(PluginResult.Status.OK, "Yay, Success,First Plugin for android!!!"+data.getString(0));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
return new PluginResult(PluginResult.Status.ERROR, "Oops, Error :(");
}
}
return null;
}
} `
我得到了这个错误
09-13 09:53:44.387: W/System.err(330): java.sql.SQLException: opening db: 'tempdb.db': Read-only file system