Advertisement
rachmadi

Utilities

Jul 14th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. import android.content.Context;
  2. import android.content.SharedPreferences;
  3. import android.preference.PreferenceManager;
  4.  
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.Date;
  8. import java.util.Locale;
  9.  
  10. public class Utilities {
  11.  
  12.     SharedPreferences sp;
  13.     SharedPreferences.Editor editor;
  14.     String value, category, location_id;
  15.     String dateTime;
  16.  
  17.     public String getUrl(String phpFile){
  18.         String url = "http://hosting.mdp.ac.id/plesir/api/" + phpFile;
  19.         return url;
  20.     }
  21.  
  22.     public void setCategory(Context context, String category){
  23.         sp = PreferenceManager.getDefaultSharedPreferences(context);
  24.         editor = sp.edit();
  25.         editor.putString("category", category);
  26.         editor.commit();
  27.     }
  28.  
  29.     public String getCategory(Context context){
  30.         sp = PreferenceManager.getDefaultSharedPreferences(context);
  31.         value = null;
  32.         category = sp.getString("category", value);
  33.         return category;
  34.     }
  35.  
  36.     public void setLocationId(Context context, String location_id){
  37.         sp = PreferenceManager.getDefaultSharedPreferences(context);
  38.         editor = sp.edit();
  39.         editor.putString("location_id", location_id);
  40.         editor.commit();
  41.     }
  42.  
  43.     public String getLocationId(Context context){
  44.         sp = PreferenceManager.getDefaultSharedPreferences(context);
  45.         value = null;
  46.         location_id = sp.getString("location_id", value);
  47.         return location_id;
  48.     }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement