Android Question Need advice for storing Data to cloud and ... (B4X)

ilan

Expert
Licensed User
Longtime User
hi,

i have 2 issues that i would like to consult with you guys.

#1
i have an app with about 25k users. the users are storing data to an kvs file with custom types.
what i have implemented now for the backup solution is to backup the db file to an external storage or even upload it to google drive so the user can download it if he switch to another phone.

the problem is that you have to back up it manually. and most dont do it. now i want to implement an auto backup option that runs once per day. so what i have tought is to use firebase auth to let the user log in with his google account and send the backup file named with his username (email) to my server.

i dont like this solution because :

1, 25k users will send files to my server?? to much storage will be needed.
2, if the file is send and overwrite the old file, there is a risk that the user will send an empty file after switching to a new phone and all data will be lost, what i could do is always send a new file with date but that will lead to too much storage as mentioned in point 1. (in 1 week = 7 backup files * 25k users)

so i am sure there is another solution for that, like using mysql db and create for each user an mysql db but i am not sure if it is possible on my server (have so much db's)

another solution is to upload it to his google drive account but is this possible? i mean an auto upload option to google drive or dropbox??

any other solution is very much appreciated.

#2
now my other problem.
i want to create an app that user can load money to it like pay 20$ via paypal and have on his account 20$ in the app and purchase digital products with that money.
my question is how to make it safe enough? i want to use b4j for that. i was thinking to use firebase auth to let the user login to his account but firebase is a mobile lib so i cannot use it with b4j. i could use mysql (username + password) to let user login to the app but i dont think this is safe enough. anyway even if i will solve to login issue how to make it with the creadit part. so user purchase credit via paypal and use it in the app to purchase products? i could also use for this mysql db so after purchase the credit is stored in the mysql db BUT after using on several games mysql for scoreboards i am sure people hack my mysql db's. because i see scores with 6-7 numbers and thats impossible to archive so they hack it and i want to avoid people hack and put credits to their accounts and use it without buying it via paypal.

i will be very thankful for any help of you guys.

thanx, ilan
 

ilan

Expert
Licensed User
Longtime User
it would probably be

B4X:
$city = mysqli_real_escape_string($con, $city);

or

$city = mysqli_real_escape_string($con, $_GET["city"]);


unless you changed $con to $link between the code posts above?


try to stick to $_POST as $_GET is limited in size.

can you please tell me what is wrong with this:

B4X:
    $values = "('Mike', 'Big', 'john@asdasd.com'), ('asdasd', '234', 'john@232.com')";

    $sql = "INSERT INTO $table (username, email, userdata) VALUES ('$values')";
    
    mysqli_query($con, $sql);

    print "Inserted7";
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
try without the additional brackets and the unneeded single quotes (you attempted to make a string of it).

B4X:
$sql = "INSERT INTO $table (username, email, userdata) VALUES $values";
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
after spending more then 7 hours on this i give up. i cannot add a bulk of entries to mysql on 1 call. :(

ok after another hour of trying i have something.

this works for me but i am not sure its the right way todo:

B4X:
    $values = $_GET["myval"];
    $newval = str_replace("[]",",",$values);

       $sql = "INSERT INTO $table (username, email, userdata) VALUES $newval";
   
       mysqli_query($con, $sql);

       print "Inserted";

b4a code:

B4X:
        Dim values As String
        For i = 0 To 100
            values = values & "('user:" & i & "', 'email" & i & "gmail.com','userdata" & i & "')"
            If i < 100 Then values = values & "[]"
        Next
        Log(values)

        Dim j As HttpJob
        j.Initialize("", Me)
        j.Download2("http://www.sagital.net/" & "msuser8.php", Array As String ("action", "signup", "myval", values))
       
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            Log(j.GetString)
        End If
        j.Release
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
yep, seems right.

that [] replace is not needed if you store a "," seperator instead of "[]" tho.
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
There is a little thing you should investigate for #2

If you hold other peoples money you are a bank!
A bank must get proof of peoples identity and address.
This is due to the whitewash law.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
There is a little thing you should investigate for #2

If you hold other peoples money you are a bank!
A bank must get proof of peoples identity and address.
This is due to the whitewash law.

Acctually i dont hild their money they purchase credit that allow tyem to buy digital services. They cannot ask for the mobey again. So its like a game where you buy money like poker game. They dont hold your money they sell you money peckages.
 
Upvote 0
Top