Advertisement
evgeni3

for saleh

Feb 11th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.21 KB | None | 0 0
  1. package com.example.android.myamuta;
  2.  
  3. import android.annotation.SuppressLint;
  4. import android.content.Context;
  5. import android.os.AsyncTask;
  6. import android.widget.Toast;
  7.  
  8. import com.cloudant.client.api.ClientBuilder;
  9. import com.cloudant.client.api.CloudantClient;
  10. import com.cloudant.client.api.Database;
  11.  
  12. import java.util.List;
  13.  
  14. /**
  15.  * Created by android on 2/8/2018.
  16.  */
  17.  
  18. public class clsAmuta {
  19.     public String myName;
  20.    // public String mySureName;
  21.     public int myAge;
  22.     public String myAddress;
  23.     public String myPhone;
  24.     //public long myGpsLat;
  25.     //public long myGpslan;
  26.     public List<String> keyword;
  27.     //private Context context;
  28.  
  29.     public clsAmuta(){}
  30.  
  31.     public clsAmuta(String myName, int myAge, String myAddress, String myPhone,List<String> keyword) {
  32.         this.myName = myName;
  33.        //this.mySureName = mySureName;
  34.         this.myAge = myAge;
  35.         this.myAddress = myAddress;
  36.         this.myPhone = myPhone;
  37.         this.keyword=keyword;
  38.         //this.myGpsLat = myGpsLat;
  39.         //this.myGpslan = myGpslan;
  40.         //this.context=context;
  41.  
  42.     }
  43.     @SuppressLint("StaticFieldLeak")
  44.     public void writeDB()
  45.     {
  46.         final String API_KEY = "thernedgeopearctermormse";
  47.         final String API_SECRET ="cf30262a4451ff87a6662ae9517b84164308a4ee";
  48.         final String DB_NAME = "myamuta";
  49.         final String DB_GATEWAY = "b0fa0de9-42da-416e-8b51-2820a7ab4403-bluemix";
  50.  
  51.         new AsyncTask<Void,Void,Void>()
  52.         {
  53.             @Override
  54.             protected void onPostExecute(Void aVoid) {
  55.                /// Toast.makeText(context, "Data O.K", Toast.LENGTH_SHORT).show();
  56.             }
  57.  
  58.             @Override
  59.             protected Void doInBackground(Void... voids) {
  60.  
  61.                 CloudantClient client = ClientBuilder.account(DB_GATEWAY)
  62.                         .username(API_KEY)
  63.                         .password(API_SECRET)
  64.                         .build();
  65.  
  66.                 Database db = client.database(DB_NAME,false);
  67.  
  68.                 clsAmuta myData = new clsAmuta(myName,myAge,myAddress,myPhone,keyword);
  69.                 db.save(myData);
  70.  
  71.                 return null;
  72.             }
  73.  
  74.  
  75.         }.execute();
  76.  
  77.     }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement