B4A Library Dummy Data for prototyping database apps

Hi.
I want to share this library I wrote for quick prototyping database apps.
All data is hardcoded in to the library, no external files, you just add library as a reference and you are ready to go.

All fields contains 500 records of real people, addresses,etc. and source of data is free downloaded from the internet. (the lib do not require internet connection)
You have to keep it in mind that the only unsorted records across the fields match, but if you sort any field, it wont match , because there is no id that connects the data rows, but who cares, this is just example data for quick prototype.

There is 11 Fields in the library: First Name, Last Name, Company, Address,
City, Country, Postal Code, Phone1, Phone2, Email and Web address.

There is xml2bb:

DummyDataLibrary
Version:
1
Author: Jaames

Fields:

  • SORT_ASCENDING As Int
  • SORT_DESCENDING As Int
  • SORT_NONE As Int
Methods:
  • GetAddresses (SortingMode As Int) As List
    returns all the data Addresses sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetCities (SortingMode As Int) As List
    returns all the data Cities sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetCompanies (SortingMode As Int) As List
    returns all the data Companies sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetCountries (SortingMode As Int) As List
    returns all the data Countries sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetDummyData (Data As String, SortingMode As Int) As List
    returns all the data from selected Field
    You can select which field you want by passing one of the string parameters:
    FirstNames LastNames Companies Addresses Cities
    Countries Postal Phones1 Phones2 Emails Webs
    And you can sort the data by passing one of the SortingMode parameters:
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data
    Example:
    <code>Dim Data as DummyData
    Dim l As List = Data.GetDummyData("FirstNames", Data.SORT_ASCENDING)
    For x = 0 To Data.Size -1
    Log(Data.Get(x))
    Next</code>
    You can access the fields also individually


  • GetEmails (SortingMode As Int) As List
    returns all the data Emails sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetFirstNames (SortingMode As Int) As List
    returns all the data First Names sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetLastNames (SortingMode As Int) As List
    returns all the data Last Names sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetPhones1 (SortingMode As Int) As List
    returns all the data Phones1 sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetPhones2 (SortingMode As Int) As List
    returns all the data Phones2 sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetPostal (SortingMode As Int) As List
    returns all the data Postal sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data


  • GetWebs (SortingMode As Int) As List
    returns all the data Webs sorted by the given SortingMode parameter
    SORT_ASCENDING - will sort the data in ascending order
    SORT_DESCENDING - will sort the data in descending order
    SORT_NONE - will return unsorted data

Example of usage:
Copy both fils DummyDataLibrary.jar and DummyDataLibrary.xml to your additional libraries folder, add DummyDataLibrary as a reference to your project and write next code :

B4X:
Dim DummyData As DummyData
Dim l As List = DummyData.GetFirstNames(DummyData.SORT_ASCENDING)
Log(l)
Log(DummyData.GetDummyData("Cities",DummyData.SORT_NONE))

Check your Log output and you should see the list of all "First Names" field sorted ascending
and list of Cities unsorted.

There are three attached zip files:
  • DummyDataExample.zip - B4A example on how to use the lib.
  • DummyDataJavaSource.zip the java sources of the lib, so you can extend it.
  • Library.zip folder with compiled library (jar and xml) file.

ss.jpg


Have a good time! :)
Jaames
 

Attachments

  • DummyDataExample.zip
    3.5 KB · Views: 147
  • DummyDataJavaSource.zip
    135 KB · Views: 161
  • Library.zip
    85.9 KB · Views: 153
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
Nice! Could you please share how to "hardcoded all data into the library"? Is it safe to protect the data from hacker/cracker? Thank you.
 

Jaames

Active Member
Licensed User
Longtime User
Actually it is not protected at all, it can be decompiled, and inside is just string arrays. Did you see java source?
 

susu

Well-Known Member
Licensed User
Longtime User
Thank you for your answer. I used phone to browse this forum so I didn't test your code.
 
Top