[android-developers] Re: Programming for performance.

2009-07-23 Thread craig3353
Consider doing this the same way hard disks are encrypted because it's the same problem: when a user changes their disk encryption password, the entire disk is not re-encrypted. The trick is that the disk encryption software creates its own master key for encrypting the disk, and it never

[android-developers] Re: Programming for performance.

2009-07-23 Thread Kaj Bjurman
You don't need xml to represent hierarchies. You can represent your notes like this, and write your data in this way (if you want to use binary): public static byte[] encode(final ArrayListNote notes) throws IOException { int size = notes.size();

[android-developers] Re: Programming for performance.

2009-07-23 Thread gnugu
Craig, I like this, I like this a LOT! Thank you!!! On Jul 22, 11:32 pm, craig3353 craig.law...@alum.mit.edu wrote: Consider doing this the same way hard disks are encrypted because it's the same problem: when a user changes their disk encryption password, the entire disk is not

[android-developers] Re: Programming for performance.

2009-07-23 Thread gnugu
Thank you for all your answers! Here is the approach I'm going to try now: - I'll use SqLite database (Mark's suggestion). - I'll try if I can store the database file on /sdcard (I want to make it easy to backup). - I'll encrypt individual fields in the rows with the key that on the other hand

[android-developers] Re: Programming for performance.

2009-07-23 Thread fadden
On Jul 22, 1:29 pm, gnugu rho...@gmail.com wrote: In my unit test I populate the notes texts using String.format(blah blah blah %1d, index). Of course it takes a long time... Don't use String.format(). It's criminally slow. Set up a java.util.Formatter object and re-use it.

[android-developers] Re: Programming for performance.

2009-07-22 Thread Dianne Hackborn
Which part is slow, reading or writing? If it is writing, just stay the heck away from the standard XML writers, they are horrendous. There is a FastXmlSerializer with limited functionality that you could copy out of the source code for your own use:

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
Dianne, It is not reading and writing that's slow. I have a class that has Notes field (ArrayListNote). I wrote my test to create 1000 note objects and add it took 45 seconds. Because I can't get XML string out of DOM Document I can't use the Document as my storage for notes which leaves me

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
Sorry, I mean SqLite and not MySQL. On Jul 22, 11:39 am, gnugu rho...@gmail.com wrote: Dianne, It is not reading and writing that's slow. I have a class that has Notes field (ArrayListNote). I wrote my test to create 1000 note objects and add it took 45 seconds. Because I can't get XML

[android-developers] Re: Programming for performance.

2009-07-22 Thread Mark Murphy
gnugu wrote: Because I can't get XML string out of DOM Document I can't use the Document as my storage for notes which leaves me with creating all these objects as I read the XML. Correct. Don't do that for large data sets. It would be ideal for me to use MySQL to store the notes but then I

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
Hi Mark, Why? Encrypt the columns you need encrypted. Say you have a database with 100 notes. You use a password as a base for encryption key. You decide to change your password. Type in the old one and the new one. Now I have to spawn a thread that will open a transaction and decrypt and

[android-developers] Re: Programming for performance.

2009-07-22 Thread Dianne Hackborn
Just creating 1000 objects isn't going to take 45 seconds, it sounds like you have something really bad going on somewhere. With it taking that amount of time, you will probably quickly see some serious hot spots if you run the profiler. Also if you are seeing log messages about the GC running

[android-developers] Re: Programming for performance.

2009-07-22 Thread Mark Murphy
gnugu wrote: Say you have a database with 100 notes. You use a password as a base for encryption key. You decide to change your password. How frequently do you anticipate people using your application (looking up data, modifying data)? Once a minute? Once an hour? Once a day? Once a week?

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
Mark, these are all very good points!!! You are absolutely correct that I'm going wrong way making normal use painful for twice in a life time task optimization. I'll take your points. Thanks for the advice. On Jul 22, 12:16 pm, Mark Murphy mmur...@commonsware.com wrote: gnugu wrote: Say

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
Just creating 1000 objects isn't going to take 45 seconds, it sounds like I was running it in the emulator with the debugger attached. I'll check logs and try the profiler. Thanks. On Jul 22, 12:02 pm, Dianne Hackborn hack...@android.com wrote: Just creating 1000 objects isn't going to take

[android-developers] Re: Programming for performance.

2009-07-22 Thread Dianne Hackborn
Oh having the debugger attached always have a significant impact on performance. Always remember, once you say the word performance there should be a real device involved that is driving the work. On Wed, Jul 22, 2009 at 12:57 PM, gnugu rho...@gmail.com wrote: Just creating 1000 objects

[android-developers] Re: Programming for performance.

2009-07-22 Thread Richard Schilling
Yes, there were some good suggestions. And, yes, using the database is a great idea. But I have another, and I use this general approach a lot when I need to import/export data or just ship files around on a device, or when memory and performance are key. XML parsers, streaming or in-memory

[android-developers] Re: Programming for performance.

2009-07-22 Thread Richard Schilling
Oh - almost forgot. Look at the presentation from Google I/O 2009 on programming for performance and gaming (I forget the title). It was really good, because the presenter gives some other really good general performance tips. Cheers, Richard Schilling Root Wireless On Jul 22, 1:17 pm,

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
I should have known better. In my unit test I populate the notes texts using String.format(blah blah blah %1d, index). Of course it takes a long time... When I just assign a string then creating 1000 objects is no problem. Now serializing all the objects into XML (org.xmlpull.v1.XmlSerializer)

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
Richard, thanks for suggestion. My notes are structured. The app allows for the notes to be in the folders one level deep. That's why I opted for XML. I'll try to find out the presentation and post the link here for others. On Jul 22, 1:17 pm, Richard Schilling richard.rootwirel...@gmail.com

[android-developers] Re: Programming for performance.

2009-07-22 Thread gnugu
There seem to be two performance related videos on Google I/O site: Turbo-charge your UI: How to Make your Android UI Fast and Efficient (http://code.google.com/events/io/sessions/ TurboChargeUiAndroidFast.html). and Writing Real-Time Games for Android (http://code.google.com/events/io/