![](/img/trans.png)
[英]Android studio - kotlin class not found when implementing in java file - error "cannot find symbol class"
[英]Implementing external Java class in Android Studio development
我正在開發一個非常簡單的 android 應用程序,它可以讓我從給定數據庫中搜索鏈接。 我設法使用 Android Studio 毫無問題地創建了應用程序。 我有一個按鈕,旨在打開搜索欄並搜索數據庫中的項目(搜索鍵)
我創建了一個基本的 web 抓取程序(使用 Java)來收集我的數據並將其放在 IntelliJ 項目的字典中。
我的問題是:如何將訪問數據庫(Java/IntelliJ 字典)連接到我的 android 應用程序(Android-Studio)中的按鈕?
IntelliJ 字典有兩個功能,一個是獲取數據,一個是搜索它。 我的Android studio代碼有一個按鈕如下:
final Button ManualSearch = (Button) findViewById(R.id.DropDown);
Scanner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v){
// Access Database
// call search method ()
// search method will return data from database
}
});
您無法從移動應用程序訪問計算機上的任何目錄。 為什么你甚至將數據存儲到 IDE 的字典中,有什么目的嗎? 這就像射擊自己的腳,但代價高昂。 Instead just save to SQL, JSON or XML in the res/raw
directory and then install to Android SQLite from there. Once I've even wrote a PHP script, which converts MySQL database to Android resource XML files... directly importing to SQLite on a computer would also be an option, then one can simply copy that database.
也許您需要編寫一個服務器,並公開一個 Rest API 進行搜索。 並從您的 Android 應用程序中調用此 API。
一些參考資料:
https://www.journaldev.com/9170/restful-web-services-tutorial-java
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.