Reputation:
I'm working on a very simple android application that will let me search for a link from a given database. I managed to create the application without any trouble using Android Studio. I have a button that is designed to open a search bar and search for the item in the database (searches for Key)
I created a basic web scraping program (using Java) to gather my data and place it in a dictionary in an IntelliJ project.
My question is: How do I connect accessing the database (Java/IntelliJ dictionary) to the button in my android app(Android-Studio)?
The IntelliJ dictionary has 2 functions, one to get the data, and one to search for it. My Android studio code has one button as follows:
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
}
});
Upvotes: 0
Views: 69
Reputation: 15553
Maybe you need to write a server, and expose a Rest API for search. And invoke this API from your Android application.
Some references:
https://www.journaldev.com/9170/restful-web-services-tutorial-java
https://restfulapi.net/create-rest-apis-with-jax-rs-2-0/
Upvotes: 0
Reputation: 76639
You can't access any directory on the computer from a mobile application. Why you even store the data into a dictionary of the IDE, is there any purpose to it ?? That's alike shooting your own feet, but dearly. 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.
Upvotes: 1