我有一个Sqlite
数据库和一个Remote
数据库。我正在尝试使用Base Sync adapter
框架。我正在尝试与Xampp数据库同步。所以我不想使用任何帐户授权。我其实不知道该怎么做。直到现在我已经完成了以下工作:
public syncad(Context context, boolean autoInitialize) {
super(context, autoInitialize);
// TODO Auto-generated constructor stub
}
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
// TODO Auto-generated method stub
HttpClient httpclient2 = new DefaultHttpClient();
HttpPost httppost2 = new HttpPost("myurl/myphp.php");
try
{
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//nameValuePairs.add(new BasicNameValuePair("TaskId","1"));
nameValuePairs.add(new BasicNameValuePair("head","a"));
nameValuePairs.add(new BasicNameValuePair("des","a"));
nameValuePairs.add(new BasicNameValuePair("dateone","a"));
nameValuePairs.add(new BasicNameValuePair("datetwo","a"));
nameValuePairs.add(new BasicNameValuePair("timeone","a"));
nameValuePairs.add(new BasicNameValuePair("timetwo","a"));
nameValuePairs.add(new BasicNameValuePair("r","a"));
nameValuePairs.add(new BasicNameValuePair("s","a"));
nameValuePairs.add(new BasicNameValuePair("stat","a"));
//Toast.makeText(getActivity(),"in"+phno.getText().toString(),Toast.LENGTH_LONG).show();
//nameValuePairs.add(new BasicNameValuePair("status",phno.getText().toString()));
//String f=phno.getText().toString();
//Log.w("communityfragment",f.toString());
/*SharedPreferences prefs=getActivity().getPreferences(0);
SharedPreferences.Editor edt=prefs.edit();
edt.putString("mynumber",f);
edt.commit();
*/
Log.i("task from namevaluepairs",""+nameValuePairs.toString());
httppost2.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response1 = null;
response1 = httpclient2.execute(httppost2);
}
catch(Exception e)
{
e.printStackTrace();
}
我想开始同步活动中的按钮点击。是否可能,我正在做的是正确的