SQlite – enable log events and see it in logcat

Create .bat file with commands provided below:

adb shell setprop log.tag.SQLiteLog V
adb shell setprop log.tag.SQLiteStatements V
adb shell su 0 stop
adb shell su 0 start

After You execute app, You (in this case) emulator will reboot.

Now search in logcat something like this below:

/data/user/0/{APP_PACKAGE_NAME}/databases/{APP_DATABASE_NAME}

Working example POST in android

Here is another short (IMHO) example how to post in android app.

private void postSms(String text) {
URL url;
HttpURLConnection urlConnection = null;

try {
url = new URL("http://yourserver.com/sendsms");
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setDoOutput(true);

List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("sms", text));//POST param as "sms"

OutputStream os = urlConnection.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
writer.write(getQuery(params));
writer.flush();
writer.close();
os.close();

String status = new String(Streams.getBytes(urlConnection.getInputStream()));
Log.d(TAG, new Exception().getStackTrace()[0].getMethodName() + ":insert status=" + status);

} catch (MalformedURLException | ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

This is a method for concatenating parameters for POST

Continue reading “Working example POST in android”