Question: Hello, I am trying to add a permanent database using SQLite to my android studio gps code using api 2 7 can you please help

Hello, I am trying to add a permanent database using SQLite to my android studio gps code using api 27can you please help me make the database helper java class and tell me how to add it into my code with steps. I am very new to android studio so please make it easy for me.I dont want to change my code. My gps app works but the information doesnt store permenantly so please tell me how i can do it. Please make it very simple. here is a section of my code mainactivity.java so you can help adapt to it.
private void showInputDialog(String locationText){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog_input, null);
EditText countryInput = dialogView.findViewById(R.id.countryInput);
RatingBar ratingBar = dialogView.findViewById(R.id.ratingBar);
builder.setView(dialogView)
.setTitle("Add Location Details")
.setPositiveButton("Save",(dialog, which)->{
String country = countryInput.getText().toString();
float rating = ratingBar.getRating();
if (!country.isEmpty()){
String entry = locationText +"| Country: "+ country +"| Rating: "+ rating +" stars";
locationList.add(entry);
adapter.notifyDataSetChanged();
Toast.makeText(this, "Location saved!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Please enter a country.", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("Cancel",(dialog, which)-> dialog.dismiss())
.create()
.show();
}
}
The full code is way to big to send so please try to use what you can. After the app records your ip, it will save it with the rating and location name but when you close the app, all the data is gone which is why you need a sqlite permenant database to save all the information. Please use what you can and make it very simple and easy for me to understand

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!