【问题标题】:How to Access my SQLite Database Values through Mobile Browsers using PHP?如何使用 PHP 通过移动浏览器访问我的 SQLite 数据库值?
【发布时间】:2017-11-20 15:45:47
【问题描述】:

我是 Android 开发新手,我对 SQLite 数据库有疑问。 我知道 Android 是一个移动操作系统,而 SQLite 是 Android 的内置数据库。 而且我知道如何使用 java 和其他东西(如 Syc 与 SQLite 和 MySQL)访问 SQLite 数据库。 我的问题是我是否有一个应用程序并将值存储在 SQLite 数据库中,如果有任何可能的方法来访问它 使用 android 移动浏览器的值?可能是我使用 PHP 从 SQLite 获取数据? 是否有可能或会出现任何安全问题(违反规则)?

【问题讨论】:

  • 查看这个库 github.com/amitshekhariitbhu/Android-Debug-Database 。这可能会有所帮助
  • 有很多方法,例如,您可以在外部存储中保留 db 的副本,并在访问给定 API 时从浏览器中使用它。但这会引发安全问题。我不建议这样做。出于调试目的,它很好,但不适用于生产。
  • 感谢链接,但我需要不使用库。 @雷德曼
  • 我尝试从外部存储中获取数据,但安卓不允许我。 .@TheLittleNaruto
  • @Moorthy 只是想了解他在图书馆里做什么

标签: android sqlite


【解决方案1】:

尝试在 Android 应用程序和 PHP 端使用 JavaScriptInterface 从 JavaScript 获取数据 像这样

public class JavaScriptInterface {
            Context mContext;

            JavaScriptInterface(Context c) {
                mContext = c;
            }
            @JavascriptInterface
            public int getconsentid() {
                return consentid;
            }
            @JavascriptInterface
            public int getrequestno() {
                return requestno;
            }
                @JavascriptInterface
            public String getAllergyName() {

                String AllergyNames = "";
                SQLiteDatabase db = new DatabaseHelper(InmateAssessment.this).getWritableDatabase();
                String query = "select AllergyName from lstAllergy order by AllergyName";
                Cursor cursor = db.rawQuery(query, null);
                for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                    AllergyNames += cursor.getString(cursor.getColumnIndex("AllergyName")) + "|";
                }
                AllergyNames = AllergyNames.substring(0, AllergyNames.length() - 1);
                cursor.close();
                db.close();
            return AllergyNames;
        }

在网页端使用Javascript来获取这些方法

#boxes .window {
    position: fixed;
    left: 0;
    top: 0;
    width: 450px;
    height: 450px;
    display: none;
    z-index: 9999;
    background-color: #c9d9f6;
}

    var pid = window.jsondata.getpid();
    var sid = window.jsondata.getsid();
    var userid = window.jsondata.getuid();
    var flag = window.jsondata.getisserch();
    var formscreenid = window.jsondata.getscreenid();

【讨论】:

  • 该帖子与在不在应用程序/webview 内的 Web 浏览器中访问数据有关
猜你喜欢
  • 1970-01-01
  • 2016-10-09
  • 2011-09-07
  • 1970-01-01
  • 2016-07-16
  • 2015-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多