码迷,mamicode.com
首页 > 移动开发 > 详细

Android连接百度云数据库demo

时间:2015-02-04 12:54:58      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

new GetPosTask("GetGroupPos.php").execute();//启动异步类,括号里面为php名称


public class GetPosTask extends AsyncTask<Void, Void, List<Info>> {//Info是自定义的类
		String url;
		public GetPosTask(String url){//获得php文件名
			this.url=url;
		}
		protected List<Info> doInBackground(Void... params) {//自动执行
			JSONObject jsonObject = null;
			//往php文件里面传参数
			List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
			list.add(new BasicNameValuePair("groupID", groupID));

			try {
				jsonObject = MyNetUtil.sendGetRequest(Constants.BASEURL + url,//启动
						list);
				if (jsonObject != null) {
					JSONArray jsonArray = jsonObject.getJSONArray("GroupPos");//json数组要与php文件里面的匹配
					for (int i = 0; i <= jsonArray.length(); i++) {
						JSONObject jsonObject1 = (JSONObject) jsonArray.get(i);
						String objectIcon = jsonObject1.getString("objectIcon");
						String objectID = jsonObject1.getString("objectID");
						String objectName = jsonObject1.getString("objectName");
						String objectAddress = jsonObject1
								.getString("objAddress");
						String objectCompany = jsonObject1
								.getString("objectCompany");
						double infoLat = jsonObject1.getDouble("infoLat");
						double infoLng = jsonObject1.getDouble("infoLng");

						info_all.add(new Info(R.drawable.a01, R.drawable.maker,
								objectID, objectName, objectAddress,
								objectCompany, infoLat, infoLng));
					}
				}

			} catch (Exception e) {
				e.printStackTrace();
			}

			return info_all;
		}
		
		@Override
		protected void onPostExecute(List<Info> result) {//接着上面执行完之后执行此部分,result是上面的返回值info_all
			super.onPostExecute(result);
			//下面写从云数据库得到数据后要进行的操作
			
		}
		
	}


Android连接百度云数据库demo

标签:

原文地址:http://blog.csdn.net/crescent__moon/article/details/43484605

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!