Getting PostgreSQL Table Data

To get table resource table data in PostgreSQL data source from mobile platform server without loading to database, create the TableActivity application, which uses the table method implemented in the RequestAPI unit.

Before creating an application make sure that the resource is available in PostgreSQL data source. The table consists of three columns containing information about fruits: id, name, description.

The TableActivity application includes one screen and a button:

To view application work results, use the interactive example:

Click the TABLE button.

public class TableActivity extends AppCompatActivity {
   private static final String MY_URL = "http://testmasterfmp.fsight.cloud/";
   private static final VersionAPI MY_VERSION_API = VersionAPI.V_1;
   private static final String MY_ENVIRONMENT = "Leonid_environment";
   private static final String MY_PROJECT = "Leonid_project";
   private static final String MY_VERSION = "v1";
   private static final String MY_LOGIN = "Leonid";
   private static final String MY_PASSWORD = "123123";
   private static final String MY_RESOURCE = "Leonid_postgreSQL";
   private static final String TAG = "TableStreamActivity";
 
   private HyperHive hyperHive;
   private TextView textView;
 
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_table);
       textView = findViewById(R.id.text_view_table);
 
       Handler uiHandler = new Handler();
 
       hyperHive = new HyperHiveState(getApplicationContext())
               .setHostWithSchema(MY_URL)
               .setApiVersion(MY_VERSION_API)
               .setEnvironmentSlug(MY_ENVIRONMENT)
               .setProjectSlug(MY_PROJECT)
               .setVersionProject(MY_VERSION)
               .setHandler(uiHandler)
               .buildHyperHive();
       authentication();
   }
 
   public void authentication() {
       boolean status = hyperHive.authAPI.auth(MY_LOGIN, MY_PASSWORD, true).execute().isOk();
       showStatus(status);
   }
 
   public void table(View view) {
       // Create parameters for the TableCallParams request
       TableCallParams tableCallParams = new TableCallParams();
       String data = "{\"upsert_rows\": null ,\"delete_ids\": null}";
       tableCallParams.setData(data);
 
       // Send the table request
       String response = hyperHive.requestAPI.table(MY_RESOURCE, tableCallParams).execute();
       textView.setText(response);
   }
 
   public void showStatus(boolean status) {
       Log.d(TAG, "auth: " + status);
       Toast.makeText(this, "auth: " + status, Toast.LENGTH_LONG).show();
   }
}

See also:

Examples of Android Framework Use | Examples of Working with Resources