I am developing an android app that uses nostra13 library. First, nostra13 uses a class file that contains array of strings which are the urls of the images to be downloaded.
ex.
public static final String[] IMAGES = new String[]{
"http://www.ltp.com.ph/SiteImages/Technilink/TL_1Q13_CE.jpg",
"http://www.ltp.com.ph/SiteImages/Technilink/TL_4Q12_CE.jpg",
"http://www.ltp.com.ph/SiteImages/Technilink/TL_2Q12_CE.jpg",
"http://www.ltp.com.ph/SiteImages/Technilink/TL_1Q12_CE.jpg",
"http://www.ltp.com.ph/SiteImages/Technilink/TL_4Q11_CE.jpg",
"http://www.ltp.com.ph/SiteImages/Technilink/TL_2Q11_CE.jpg",
"http://www.ltp.com.ph/SiteImages/Technilink/TL_1Q11_CE.jpg",
"http://www.ltp.com.ph/SiteImages/Technilink/TL_4Q10_CE.jpg"
};
Is there a way to update this string array online? Like I want to put some file online then the app would download it and update the String[] IMAGES? THANKS!
You could change the value stored in each array position with new data obtained on-line, but you would not be able to change the length of the array because it is declared final
.
A better approach is to think of the IMAGES
array as the source of data for initializing your working array, which you could store in persistent store (e.g., SharedPreferences
or SQLite data base—see the guide topic Storage Options). When you retrieve new data from the web, you can then easily replace or update the stored data. You would only use the IMAGES
array to initialize your working array and ignore it after that (unless you added a "reset" function to return to the original data).