更新数据库phpMyAdmin


Update database phpMyAdmin

我有一个数据库,我在我的应用程序上运行phpmyadmin。一切都很好,但我想知道是否有办法检查数据库的最新更新。这是我的java代码:

try {
   String s = "";
   JSONArray jArray = new JSONArray(result);
   for(int i=0; i<jArray.length();i++){
       JSONObject json = jArray.getJSONObject(i);
       locale[i]=json.getString("Locale");
       lunedi[i]=json.getString("Lunedi");
       martedi[i]=json.getString("Martedi");
       mercoledi[i]=json.getString("Mercoledi");
       giovedi[i]=json.getString("Giovedi");
       venerdi[i]=json.getString("Venerdi");
       sabato[i]=json.getString("Sabato");
       domenica[i]=json.getString("Domenica");
       info1[i]=json.getString("info1");
       info2[i]=json.getString("info2");
       info3[i]=json.getString("info3");
       info4[i]=json.getString("info4");
       info5[i]=json.getString("info5");
       info6[i]=json.getString("info6");
       info7[i]=json.getString("info7");
       id[i]=json.getString("id");
       s = s + 
               "Id : "+json.getInt("id")+"'n'n";
   }

谢谢。

你可以在后台运行一个服务,检查是否有更新

public class NotifService extends Service {
public NotifService() {
}

public void onCreate() {
    //when the service created
    super.onCreate();
}
@Override
public IBinder onBind(Intent intent) {
    return null;
}
@Override
public void onStart(Intent intent,int startId) {
    super.onStart(intent,startId);
    isRunning = true;
    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
            super.handleMessage(msg);
           //**** do your woek here : in your case connect to your database and see  
         if there is some new tuples **************/
        }
        }
    };

   //every 30 min the service will call
    new Thread(new Runnable(){
        public void run() {
        // TODO Auto-generated method stub
        while(isRunning)
        {
           try {
            Thread.sleep(1800000);//30min =1800000
            handler.sendEmptyMessage(0);
           } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
           } 
        }
                        }
    }).start();
}
@Override
public void onDestroy() {
    isRunning = false;
    super.onDestroy();
}

}

和启动服务,你写

 startService(new Intent(this, NotifService.class));

关闭服务写

 stopService(new Intent(this, NotifService.class));