1

What is the best way for storing Path values persistenly? Between the options mentioned here, I would say the best option would be SharedPreferences. But can I also store some like a Path on SQLite Databases?(I feel I can't,because databases don't have any value type for anything like Path). But, on the other hand,is there any limitation(mostly memory related) to storing data with SharedPreferences?

I'm stuck in this problem very badly. Kindly help. Any suggestion is also most welcome.Also, any form code would also be appreciated. Though, a guidance should be enough.

Another problem related to this is, Path values generated on my emulator will be different on the mobiles that the application will run on(screen size difference,and hence the issue). How should I go about tackling this??

Kazekage Gaara
  • 14,972
  • 14
  • 61
  • 108

1 Answers1

1

I wouldn't recommend to store this kind of data in SharedPreferences as you will have to implement many thinks like getCount() etc which SQLite already offers.

Did you think about using Serialization for your Path objects? You could easily store them in your database afterwards.

Tim
  • 6,692
  • 2
  • 25
  • 30
  • I actually need to store many Path values now(during the training phase of my application),and when a user will use this application,the Path values generated by them will be compared to the Path values stored during training,and based on the comparison,results will be returned. So will Serialization be of any significance when it comes down to comparing again with Path objects? – Kazekage Gaara Mar 16 '12 at 13:15
  • 1
    Normally you wouldn't use the SharedPreferences for a prefilling mechanism (of course you can do that). Especially if you want to do stuff like comparison you definitely should choose a database. Store the values you need for your comparison and query for them afterwards. I don't think that you'll have to serialize a whole Path object in your db. – Tim Mar 16 '12 at 13:18
  • And could you please tell about how to store Path values in a way that they are compatible for every phone and every screen size? :-) Your help so far has been of great use! :-) – Kazekage Gaara Mar 16 '12 at 13:21
  • 1
    Try to implement a CustomPath that extends Path and implements Serializable. Furthermore add for every custom class that can be attached to a Path the interface by extending it. A Path is only a container for other objects (like Rects). Have a look at Path's source: https://github.com/android/platform_frameworks_base/blob/master/graphics/java/android/graphics/Path.java – Tim Mar 16 '12 at 13:28
  • 2
    Furthermore you could have a look at this http://stackoverflow.com/questions/8832931/can-i-serialize-the-paths-drawn-on-canvas-for-redrawing-the-paths-on-relaunch-of – Tim Mar 16 '12 at 13:31