java使用安卓加速远程数据检索
好的,我正在为大学做这个项目,我正在努力想办法优化我的cope,让它运行得更快
首先,我通过连接facebook获取了一个用户列表,这根本不需要花太长时间。然而,对于每个用户,我需要获取存储在远程MySQL数据库中的数据。所以要做到这一点,我使用以下方法
// gets arraylist of users
ArrayList<User> userList= getList();
// ok so for the next bit, for each user in the arraylist i get their data on the
database.
for (User u: userList){
u.setResultList(retireveData(u));
if (u.getResultList()!=null){
//do some magic :)
}
}
好了,就这样。。。我的想法是,第一次需要很长时间,是的,但是我可以将数据存储在本地sqlite数据库中,这样以后它运行得更快,并且只在添加新数据时更新数据。有什么建议吗
# 1 楼答案
嗯。。。我想你需要一个游标适配器
当新数据进来时,它会更新你的视图。 请参阅此链接-http://thinkandroid.wordpress.com/2010/01/13/custom-baseadapters/