How can I securely (indirectly) query a postgresql database within android?

后端 未结 2 904
庸人自扰
庸人自扰 2020-12-17 06:09

The current solution that I have to adopt uses JDBC and stores the user/password of the database inside the android app. That\'s as far as I\'m concerned not a good solution

2条回答
  •  星月不相逢
    2020-12-17 06:43

    Is there a best practise:

    It depends on the person. All have their strength and weakness. I prefer, and I think many but not all will agree on JSON cause it is really easy to use in Android. It's also lightweight and very easy to use in php. Php has methods to convert an array/object to json and back.

    It is indeed not recommended to save your postgres data on an android device.

    My strategy is usually:

    PHP server side with a POSTGRESQL database, using PDO to communicate between my models and the database.

    If you are not familiar with PDO(php data objects), I recommend you make yourself familiar with it.

    php.net PDO

    Android as client, using JSON as method of transfering data from and to.

    There are many examples that can help you.

    Android has standard libraries to handle json parsing.

    See this answer for an example:

    example

提交回复
热议问题