Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.android.myamuta;
- import android.annotation.SuppressLint;
- import android.content.Context;
- import android.os.AsyncTask;
- import android.widget.Toast;
- import com.cloudant.client.api.ClientBuilder;
- import com.cloudant.client.api.CloudantClient;
- import com.cloudant.client.api.Database;
- import java.util.List;
- /**
- * Created by android on 2/8/2018.
- */
- public class clsAmuta {
- public String myName;
- // public String mySureName;
- public int myAge;
- public String myAddress;
- public String myPhone;
- //public long myGpsLat;
- //public long myGpslan;
- public List<String> keyword;
- //private Context context;
- public clsAmuta(){}
- public clsAmuta(String myName, int myAge, String myAddress, String myPhone,List<String> keyword) {
- this.myName = myName;
- //this.mySureName = mySureName;
- this.myAge = myAge;
- this.myAddress = myAddress;
- this.myPhone = myPhone;
- this.keyword=keyword;
- //this.myGpsLat = myGpsLat;
- //this.myGpslan = myGpslan;
- //this.context=context;
- }
- @SuppressLint("StaticFieldLeak")
- public void writeDB()
- {
- final String API_KEY = "thernedgeopearctermormse";
- final String API_SECRET ="cf30262a4451ff87a6662ae9517b84164308a4ee";
- final String DB_NAME = "myamuta";
- final String DB_GATEWAY = "b0fa0de9-42da-416e-8b51-2820a7ab4403-bluemix";
- new AsyncTask<Void,Void,Void>()
- {
- @Override
- protected void onPostExecute(Void aVoid) {
- /// Toast.makeText(context, "Data O.K", Toast.LENGTH_SHORT).show();
- }
- @Override
- protected Void doInBackground(Void... voids) {
- CloudantClient client = ClientBuilder.account(DB_GATEWAY)
- .username(API_KEY)
- .password(API_SECRET)
- .build();
- Database db = client.database(DB_NAME,false);
- clsAmuta myData = new clsAmuta(myName,myAge,myAddress,myPhone,keyword);
- db.save(myData);
- return null;
- }
- }.execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement