我可以直接从android程序访问远程SQL数据库(在Web服务器上)吗?即只需打开具有所有必需参数的连接,然后执行SQL查询?
这是一个私人程序(不向公众提供),仅适用于指定的手机,因此我并不担心第三方获得数据库访问权限.
如果是这样 - 我在Java中需要哪些库?
谢谢.
完成后在iPhone上结束应用程序的正确方法是什么?
谢谢,
安东
我已经构建了一个用于访问WEB API服务的java例程,但是我正在为ASP.Net的VB等价物而苦苦挣扎.我得到API响应,但我不知道如何将其转换为json元素.
java版本是:
public boolean canLogin(){
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(hostURL + TOKEN_ACCESS_URL);
httppost.addHeader("Accept", "application/json");
// Add the post content
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs.add(new BasicNameValuePair("grant_type", "password"));
nameValuePairs.add(new BasicNameValuePair("username", accessUserName));
nameValuePairs.add(new BasicNameValuePair("password", accessPassword));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e1) {
mobileLogDataHandler.ToLog(LogType.Error, "UnsupportedEncodingException closing data stream with error: " + e1.getLocalizedMessage() + ",detail:" + e1.getMessage() + " in canLogin", mResolver, RemoteDataHandler.class);
return false;
}
// post the server
InputStream inputStream = null;
String …
Run Code Online (Sandbox Code Playgroud)