I have a listview having three fields , but I don't know how to save my listview in android
and fetch it back when user open app and display it.
I want to show the data saved in listview and I have to save the new data which user enter into my listview.
Try this: my_listview. setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { } });
xml. Create an another layout file (list_row. xml) in /res/layout folder to show the data in listview, for that right click on layout folder à add new Layout resource file à Give name as list_row.
just check if (cartlist. size()<0) then yours list is Empty.!
I would recommend having some sort of database on a server that would save that information and that you would need to pull that information from the database to display it in the app. However, android also has something called a sharedpref that allows you to save stuff in the app when the app is closed. The link is below. However this is not the best way a database would be, but it may work for your needs.
http://developer.android.com/reference/android/content/SharedPreferences.html
As per your requirment, there is no direct way to store list view, but you can store the data in the list view and you can set it in to the ListView later, for that you have to use Sqlite Database, refer official documentation of sqlite here, also check out this example.
read this example too (ListView of Data from SQLiteDatabase )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With