currently I am developing an app for my final class in college. The concept of the app is a Contact keeping app, essentially a user will be greeted by a login screen where they can either login if they already have an account or register if they don't. When you register the user will be prompt to enter their name, username, password and email. They then submit it and they will again be greeted by the login screen where they can now login in with their recently created credentials. Once they login successfully they be be show an Activity that welcomes them with their name that is retrieved from the table in the database by matching the username and password on the login, it retrieves all the information in that row. I pretty much have that down but what I am having trouble with is where am I going to hold the contacts that the users wants to save, I know that is has to be in another table but how am I going to set it up so I can match the a certain user to all of their contacts in the other table.
Once I get that information I need to put it on a ListView so the user can see their contacts and scroll through them, they can then add, delete or edit them.
As of right now I am able to register, login and display the welcome screen with no problem now I just need to be able to add, delete and edit contacts.
Dalam materi tentang Cara Koneksi Android dan Mysql kita menggunakan operasi dasar CRUD (Create, Read, Update dan Delete). Proses Input, Baca, Ubah dan Hapus data melalui aplikasi Android.Operasi ini lumrah digunakan pada setiap pemrograman. Kita akan contohkan salah satu aplikasi penyimpanan data mahasiswa. Pada kesempatan ini kita akan menggunakan IDE Android Studio dan Geny Motion untuk. Oke langsung saja kali ini kita akan bahas tentang cara input data, update data dan hapus data dari android ke database MySQL dengan perantara PHP. Yah PHP ini ibarat mak comblang antara android dan MySQL. Sekarang mari kita mulai membuat aplikasi android yang mempunyaiu kemampuan CRUD ke database MySQL.
Java is used for the Android Studio part and PHP is used for the file that make the connection in the host online.
I am using Volley and JSON request.
The database and PHP files that make the request to the database are hosted in 000webhost.
T. EsparzaT. Esparza
2 Answers
This seems like a simple CRUD application.If you use a RESTful communication model it's quite simple to achieve.As for storing the contacts, you can have a file specific to each user and have that file's URI on the user's table in the DB. The file can be CSV, or JSON which is easily convertable into POJOs with the right API.
Good luck.
ricol070ricol070
First, create a MySQLite Helper class
Then a model class
Then a datasource
You access the datasource as follows:
You can display the info in a listview by calling ContactsDataSource.getAllContacts(), and displaying the results using a custom listAdapter. The idea is that you will use the Data Source's functions to grab the data you want, and feed it into the model class. From there you can extract what you need for the listview. Let me know if you need more help with that.
You also mentioned wanting to make multiple tables in the database, and that is as easy as using the above code but just adding another variable, such as TABLE_CONTACTS2 = 'contacts2', and duplicating the functions for that table.
emhomm4emhomm4
Not the answer you're looking for? Browse other questions tagged javaphpandroidmysqldatabase-design or ask your own question.