juhsteezy
juhsteezy

Reputation: 13

best way to save a python dictionary for use in java/android?

Sorry, this might be a dumb question. I have a large dictionary in python that i hope to save to file and use the data in an android app. I have read on here i can save the dictionary using pickle, json or an sqlite database. I have no experience with databases or json and while I'm willing to learn, I dont know which format is best for my purposes. I know android uses sqlite but can i easily load a db created in python in java? Or is using an sqlite database an overkill? thanks.

my dictionary is fairly simple:

data = {'category1':[list1, list2],'category2':[list4, list5]}

Upvotes: 1

Views: 498

Answers (1)

Janis F
Janis F

Reputation: 2640

I personally would go the JSON-route. You can serialize your Python Dictionary with pickle or simple_json, and there are quite a bunch of JSON-libraries for Java, too. (I used this one, worked like a charm.)

The database seems to be a fairly bad choice for transporting data. The use case for a database is an entirely different one.

Upvotes: 1

Related Questions