Android Question Need persistent storage for counts

chuck3e

Active Member
Licensed User
Longtime User
I have a 14 question quiz on an Android tablet and for each question I want to save in a file the number of times it's incorrectly answered. Later, maybe days later, I want to access that file to produce statistics. I would like to not have to add external memory if possible. I've been trying to understand file types and manipulation but the how to is not sinking in. I have looked through the beginners guide and sample code snipets but can't relate to what's there. Is there a sample code somewhere that shows how to simply read and write a line containing an integer (the total of incorrect answers) that is accessed by a key (the question number)? Is RandomAccess a good way to go about this?
 

chuck3e

Active Member
Licensed User
Longtime User

Erel, It looks like KeyValueStore will do the job for me but I have been trying to use it and I can't figure out how to make it available to my code. Looking through the documentation, Beginner and Userguide, I can see what needs to be done but it doesn't tell me how. I have gotten the authorization and I went to the list of added libraries and found it but there is no download button there just a tutorial. I unzipped a .zip file I found at the end of the tutorial into C:\Android\AddLibraries and I made sure the path to AddLibraries was correct and in IDE I clicked on every visible library member in the libs list at the right of my code but KeyValueStore still shows up red in my code. I have the feeling I'm again missing some simple step. It looks like what unzipped was just sample code .b4a file and a .bas file. Other library modules don't look like this, they are .jar and .xml, so I think I'm going to the wrong place.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@Chuck: The KeyValueStore is a class not a library. You need to add the class module in Erel's example 'KeyValueStore.bas' to your project. It is the .bas file. The 2 additional libraries you need are the RandomAccessFile and SQL.
 
Upvote 0

chuck3e

Active Member
Licensed User
Longtime User
@Chuck: The KeyValueStore is a class not a library. You need to add the class module in Erel's example 'KeyValueStore.bas' to your project. It is the .bas file. The 2 additional libraries you need are the RandomAccessFile and SQL.

Mahares,
Thanks! You helped me figure it out. I knew I had to be on the wrong track. This is tough without formal training.
-Chuck
 
Upvote 0
Top