【发布时间】:2016-02-09 21:00:52
【问题描述】:
我在我的 Ionic 应用程序上使用 pouchdb,目前正在处理 DOMException code:18 错误。 文档要求我更改 android 的设置。
编辑 我发现我必须在 MainActivity.java 中进行这些更改 这是我写的代码。
import android.os.Bundle;
import org.apache.cordova.*;
import android.content.Context;
import android.view.Menu;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class MainActivity extends CordovaActivity
{
WebView webView = null;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
webView = (WebView) findViewById(R.id.webView);
WebSettings settings = webView.getSettings();
settings.setDatabaseEnabled(true);
String databasePath = getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
settings.setDatabasePath(databasePath);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(estimatedSize * 2);
}
});
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
当我编译这个我得到错误 - R.id.webView -> 看来我的资源名称不正确,它在资源中找不到 webView。我搜索了平台/android 文件夹,但找不到布局文件。 另外,我没有使用 eclipse,我使用 atom 编辑器进行离子项目。
【问题讨论】:
标签: android cordova ionic-framework android-webview pouchdb