Re: [android-developers] ORM library

2013-05-10 Thread Ryan Bateman
Your points are valid and to similar to my own concerns.  While I doubt 
that ORM would save the day, it would be nice to have a solution that would 
reduce the large amount of boilerplate that comes along with maintaining 
table structures.
I'll take a look at ORMLite - thanks for your thoughts.  

On Thursday, 9 May 2013 17:17:28 UTC+1, mbanzon wrote:
>
> I have looked at quite a few ORM libs but have always decided to go 
> without them. 
>
> I think that ORMs works a lot better in dynamic language environments 
> like PHP and Ruby. That is just my personal opinion - they might work 
> just fine. 
>
> Secondly my main concern when writing apps for Android is the overall 
> device power consumption that my apps inflict. I have absolutely no 
> empirical data to support the following statement - but my general 
> conception is that computing and I/O is very expensive and should be 
> avoided at all costs. It is also my thought that ORM libs doesn't help 
> me do as little (especially I/O) as possible. 
>
> So - the main reason I have chosen to go without any ORM lib so far is 
> that weighing the complexity and maintenance of the domain model 
> against the hand writing and optimizing of SQL clearly favours the 
> hand-written approach. This is clearly because of a very limited 
> domain and "deeper" apps with data only slightly more complex might 
> benefit greatly from using an ORM lib without taking any significant 
> performance or battery consumption impact. 
>
> The ORM library I have been most pleased with (as far as I remember) 
> is OrmLite: http://ormlite.com/sqlite_java_android_orm.shtml 
>
> If you gather any experience please share - it would be interesting to 
> hear about cases where using an ORM library "saves the day" ;-) 
>
> On Thu, May 9, 2013 at 2:14 PM, Ryan Bateman 
> > 
> wrote: 
> > Hi all, 
> > 
> > I was wondering whether anyone would be able to recommend any specific 
> ORM 
> > libraries? I've seen a few but not heard much in the way of personal 
> > experiences with any of them. My main concerns would be optimisation 
> when 
> > querying across object relationships (i.e. get me all users with photos 
> > should ideally, under the hood, be running one SQLite query). 
> > 
> > Any thoughts or experience appreciated. 
> > 
> > Ryan 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Android Developers" group. 
> > To post to this group, send email to 
> > android-d...@googlegroups.com 
> > To unsubscribe from this group, send email to 
> > android-developers+unsubscr...@googlegroups.com  
> > For more options, visit this group at 
> > http://groups.google.com/group/android-developers?hl=en 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Android Developers" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to android-developers+unsubscr...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
>
> -- 
> Michael Banzon 
> http://michaelbanzon.com/ 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] ORM library

2013-05-09 Thread Ryan Bateman
Hi all,

I was wondering whether anyone would be able to recommend any specific ORM 
libraries? I've seen a few but not heard much in the way of personal 
experiences with any of them. My main concerns would be optimisation when 
querying across object relationships (i.e. get me all users with photos 
should ideally, under the hood, be running one SQLite query).  

Any thoughts or experience appreciated.

Ryan

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: HttpURLConnection on Galaxy Nexus 4.2

2012-11-23 Thread Ryan Bateman
That's not right, I'm afraid (unless I'm misunderstanding you.) POST 
requests for REST APIs generally have a body that contains their content.
I had a dig into the Google IO 2012 POST request code and it seems like it 
does some odd things.

  HttpURLConnection conn = null;
>
> try {
>
> conn = (HttpURLConnection) url.openConnection();
>
> conn.setDoOutput(true);
>
> conn.setUseCaches(false);
>
> conn.setChunkedStreamingMode(0);
>
> conn.setRequestMethod("POST");
>
> conn.setRequestProperty("Content-Type",
>
> "application/x-www-form-urlencoded;charset=UTF-8");
>
> conn.setRequestProperty("Content-Length",
>
> Integer.toString(body.length()));
>
> // post the request
>
> OutputStream out = conn.getOutputStream();
>
> out.write(body.getBytes());
>
> out.close();
>
> // handle the response
>
> int status = conn.getResponseCode();
>
> if (status != 200) {
>
> throw new IOException("Post failed with error code " + 
>> status);
>
> }
>
> } finally {
>
>
It sets a specific request method after already setting doOutput (which, 
apparently, forces the request to use POST) and sets a fixed-length HTTP 
header while still using chunked request mode. Which doesn't make a large 
amount of sense. 
I am at a loss and wondering if it's something to do with my internet 
service using some kind of proxy that I'm not aware of and the 
HttpUrlConnection failing to redirect somehow the first time. ('curl'ing 
the same request works fine.) 

 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: HttpURLConnection on Galaxy Nexus 4.2

2012-11-23 Thread Ryan Bateman
This also seems to happen on the Nexus 7 running 4.1 / 4.2 but again, not 
on the emulator versions. 



On Thursday, November 22, 2012 9:58:52 AM UTC, Ryan Bateman wrote:
>
> I'm attempting to write a simple API management class and running into an 
> issue when using HttpUrlConnection to POST content on a Galaxy Nexus 
> recently upgraded to 4.2. 
> In effect, attempting to post content fails on the first attempt with an 
> EOFException:
>
> java.io.EOFException
>> at libcore.io.Streams.readAsciiLine(Streams.java:203)
>> at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
>> at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
>> at 
>> libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
>> at 
>> libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
>> at com.murts.network.APIClient.post(APIClient.java:126)
>> at com.murts.network.APIManager$1.doInBackground(APIManager.java:49)
>
>
> The second attempt to post (with the same data) will work fine, as will 
> every alternate attempt to do so after that. 
>
> The code is as follows:
>
> URL url = new URL(urlString);
>> connection = (HttpURLConnection) url.openConnection();
>> connection.setUseCaches(false);
>> connection.setDoOutput(true);
>> connection.setRequestProperty("Content-type", "application/json; 
>> charset=utf-8");
>> connection.setFixedLengthStreamingMode(postContent.getBytes().length);
>>
>> output = connection.getOutputStream();
>> output.write(postContent.getBytes());
>> if (connection.getResponseCode()  / 100 == 2) {
>> Ln.d("Seemed to work: " + connection.getResponseCode());
>> return new NetworkResponse(NetworkStatus.OKAY, 
>> connection.getResponseCode(), "");
>> } else {
>> String errorResponse = new 
>> String(readStream(connection.getErrorStream()));
>> Ln.e(TAG , "Error: " + errorResponse);
>>
>> String statusLine;
>> if (connection.getHeaderFields().get(null) != null && (statusLine = 
>> connection.getHeaderFields().get(null).get(0)) != null && 
>> TextUtils.split(statusLine, " ").length > 2) {
>> int potentialStatusCode = Integer.parseInt(TextUtils.split(statusLine, " 
>> ")[1]);
>> Ln.d("Parsed out empty response to reveal: " + potentialStatusCode);
>> return new NetworkResponse(NetworkStatus.OKAY, potentialStatusCode, "");
>> }
>> }
>> } catch (IOException e) {
>> Ln.e(e);
>> } finally {
>> if (connection != null) {
>> connection.disconnect();
>> }
>> }
>
>
> Testing on a 4.2 image on an emulator seems to work well, as does testing 
> on previous versions of Android on an emulator (2.3+).  
> I can't see any immediate issues with the code (it may looks hackish in 
> parts, but that's due more to being churned over thanks to endless 
> frustration with this issue) but perhaps I've missed something? 
> Anyone have any thoughts with this, on either a Galaxy Nexus in general or 
> with 4.2 specifically?
>
> Thanks in advance for any assistance (or even thoughts at all.)
>
> Ryan
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en