List of usage examples for android.content Context MODE_APPEND
int MODE_APPEND
To view the source code for android.content Context MODE_APPEND.
Click Source Link
From source file:com.cssweb.android.common.CssIniFile.java
public static boolean saveIniWithAPPEND(Context context, int parmInt, String key, String value) { FileOutputStream fileOut = null; Properties properties = new Properties(); properties.put(key, value);/*from w w w . j a v a2s . c o m*/ try { fileOut = context.openFileOutput(GetFileName(parmInt), Context.MODE_APPEND);// properties.store(fileOut, ""); fileOut.close(); } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } return true; }
From source file:com.cssweb.android.common.CssIniFile.java
public static boolean delIniWithAPPEND(Context context, int parmInt, String key) { Properties properties = new Properties(); try {/*from w w w . j a v a2 s .c o m*/ FileOutputStream stream = context.openFileOutput(GetFileName(parmInt), Context.MODE_APPEND);// properties.remove(key); stream.close(); } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } return true; }
From source file:gcm.play.android.samples.com.gcm.MyGcmListenerService.java
private void saveNotification(String message) { try {//from w ww.j a v a 2s . c o m FileOutputStream fos = openFileOutput("history.txt", Context.MODE_APPEND); fos.write((getCurrentTimeStamp() + " " + message + "\n").getBytes()); fos.close(); } catch (Exception exp) { } }
From source file:io.github.jhcpokemon.expressassist.fragment.SettingFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.clear: SharedPreferences sharedPreferences = getContext().getSharedPreferences("user_msg", Context.MODE_APPEND); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("email", ""); editor.putString("password", ""); editor.putBoolean("save", false); editor.putBoolean("auto", false); editor.apply();//from w w w .j ava2s . com ExpressLog.deleteAll(ExpressLog.class); getActivity().finishAffinity(); break; case R.id.version: if (count == 0) { Dialog imageDialog = new Dialog(getContext()); ViewGroup.LayoutParams params = imageDialog.getWindow().getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; params.height = WindowManager.LayoutParams.MATCH_PARENT; imageDialog.getWindow().setAttributes((WindowManager.LayoutParams) params); imageDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); imageDialog.setContentView(R.layout.image_dialog); imageDialog.setCancelable(true); imageDialog.show(); versionBtn.setClickable(false); } else { count--; } break; case R.id.policy: Dialog policyDialog = new Dialog(getContext()) { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.policy); View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_policy, null, false); TextView policyTextView = (TextView) view.findViewById(R.id.policy); policyTextView.setText(policy); setContentView(view); setCancelable(true); ViewGroup.LayoutParams params = getWindow().getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; getWindow().setAttributes((WindowManager.LayoutParams) params); } }; policyDialog.show(); break; default: break; } }
From source file:com.uberspot.storageutils.StorageUtils.java
/** Appends data to the given file. * @param fileName the name of the file to append data to * @param data an array of bytes to append to the file * @return true if the operation was successful, false otherwise *///from w w w .j ava 2 s .c om public boolean appendToFile(String fileName, byte[] data) { FileOutputStream fos; try { fos = openFileOutput(fileName, Context.MODE_APPEND); fos.write(data); fos.close(); } catch (Exception e) { return false; } return true; }
From source file:com.gmail.charleszq.picorner.ui.MainSlideMenuActivity.java
private PhotoListCommand getDefaultCommand() { SharedPreferences sp = this.getSharedPreferences(IConstants.DEF_PREF_NAME, Context.MODE_APPEND); String defaultCommandString = sp.getString(IConstants.PREF_DEFAULT_PHOTO_LIST, "1"); //$NON-NLS-1$ switch (Integer.parseInt(defaultCommandString)) { case 1:/*from ww w. java 2 s . c om*/ return new PxPopularPhotosCommand(this); case 2: return new PxEditorsPhotosCommand(this); case 3: return new PxUpcomingPhotosCommand(this); case 4: return new PxFreshTodayPhotosCommand(this); case 5: return new FlickrIntestringCommand(this); default: return new InstagramPopularsCommand(this); } }
From source file:vt.diamond.LayoutChangesActivity.java
private void addItem(String question, boolean write) throws IOException { findViewById(android.R.id.empty).setVisibility(View.GONE); // Instantiate a new "row" view. final ViewGroup newView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.list_item_example, mContainerView, false);//w w w . ja v a 2s .com // Set the text in the new row to a random country. ((TextView) newView.findViewById(android.R.id.text1)).setText(question); if (write) { BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(openFileOutput("usrQues.txt", Context.MODE_APPEND))); writer.append(question); writer.newLine(); writer.flush(); writer.close(); } // Set a click listener for the "X" button in the row that will remove the row. newView.findViewById(R.id.delete_button).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { //remove question from local stoarage String removeString = ((TextView) newView.findViewById(android.R.id.text1)).getText().toString(); BufferedReader myQues = null; String nextln = null; try { myQues = new BufferedReader(new InputStreamReader(openFileInput("usrQues.txt"))); nextln = myQues.readLine(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //buffer to hold new contents of the file StringBuffer contents = new StringBuffer(); //copy file while (nextln != null) { if (!removeString.equals(nextln)) { contents.append(nextln + "\n"); } try { nextln = myQues.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } //rewrite the file BufferedWriter myQuesNew = null; try { myQuesNew = new BufferedWriter( new OutputStreamWriter(openFileOutput("usrQues.txt", Context.MODE_PRIVATE))); myQuesNew.write(contents.toString()); myQuesNew.flush(); myQuesNew.close(); myQues.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Remove the row from its parent (the container view). // Because mContainerView has android:animateLayoutChanges set to true, // this removal is automatically animated. mContainerView.removeView(newView); // If there are no rows remaining, show the empty view. if (mContainerView.getChildCount() == 0) { findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } } }); // Because mContainerView has android:animateLayoutChanges set to true, // adding this view is automatically animated. mContainerView.addView(newView, 0); }
From source file:com.gmail.charleszq.picorner.ui.ImageDetailActivity.java
/** * If slide show command comes directly from the offline menu item, set the 'delay' to the same as * the interval, otherwise, it means the command comes from this activity itself, then just delay for * 2 seconds./* ww w . j a v a 2 s. c o m*/ * @param delay */ void startSlideShow(int delay) { SharedPreferences sp = this.getSharedPreferences(IConstants.DEF_PREF_NAME, Context.MODE_APPEND); int interval = Integer .parseInt(sp.getString(IConstants.PREF_SLIDE_SHOW_INTERVAL, IConstants.DEF_SLIDE_SHOW_INTERVAL)); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mTimer = new Timer(); mTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { mHandler.post(new Runnable() { @Override public void run() { int currentPosition = mPager.getCurrentItem(); currentPosition++; if (currentPosition >= mAdapter.getCount()) currentPosition = 0; mPager.setCurrentItem(currentPosition); } }); } }, delay == 1 ? interval : 2000, interval); mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); getActionBar().hide(); if (BuildConfig.DEBUG) Log.d(TAG, "slide show starts..."); //$NON-NLS-1$ }
From source file:com.example.kevinrotairo.androidcodecamp.GetLocationActivity.java
public void writeToFile(String wordToWrite) { String contentsToWrite = wordToWrite; final String TAG = GetLocationActivity.class.getName(); try {//w w w. j a v a 2s . c o m //OutputStreamWriter outputStreamWriter = new OutputStreamWriter(openFileOutput(Constants.FILENAME, Context.MODE_PRIVATE)); OutputStreamWriter outputStreamWriter = new OutputStreamWriter( openFileOutput(Constants.FILENAME, Context.MODE_APPEND)); outputStreamWriter.write(contentsToWrite); outputStreamWriter.write("\n"); outputStreamWriter.close(); //Toast.makeText(getApplicationContext(), "File successfully saved!", Toast.LENGTH_LONG).show(); //readFromFile(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.arubadesignweb.app.appoverview.util.GcmIntentService.java
/** GEOLOCATED PUSH NOTIFICATIONS **/ private void addProximityAlert(Bundle extras, Location target_location, double radius) { try {//from w ww.j a v a 2s .c o m JSONObject alert = new JSONObject(); alert.put("latitude", target_location.getLatitude()); alert.put("longitude", target_location.getLongitude()); alert.put("radius", radius); alert.put("title", extras.getString("title")); alert.put("message", extras.getString("message")); alert.put("send_until", extras.getString("send_until")); alert.put("message_id", extras.getString("message_id")); String key = "push" + extras.getString("message_id"); SharedPreferences push_prefs = getSharedPreferences("geolocated_push", Context.MODE_APPEND); SharedPreferences.Editor editor = push_prefs.edit(); editor.putString(key, alert.toString()); editor.commit(); } catch (JSONException e) { e.printStackTrace(); } }