Android Open Source - Database_Sqlite_Assets_Helper Util






From Project

Back to project page Database_Sqlite_Assets_Helper.

License

The source code is released under:

MIT License

If you think the Android project Database_Sqlite_Assets_Helper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
The MIT License (MIT)/* www  .  j  ava2 s .  c om*/

Copyright (c) 2014 Ahmad Barqawi (github.com/Barqawiz)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */
package com.iaraby.db.helper;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class Util {
  
  public static void copyFile(InputStream input, OutputStream output)
      throws IOException {
    // transfer files from input file to output file
    byte[] buffer = new byte[1024];
    int length;

    while ((length = input.read(buffer)) > 0)
      output.write(buffer, 0, length);

    
  } // method: copy file
  
  public static void saveValue(String key, int value, Context context) {
    SharedPreferences prefManager = PreferenceManager.getDefaultSharedPreferences(context);
    Editor edit = prefManager.edit();
    edit.putInt(key, value);
    edit.commit();
  } //method: save preference valye
}




Java Source Code List

com.iaraby.data.DBAdapter.java
com.iaraby.db.helper.Config.java
com.iaraby.db.helper.DatabaseAdapter.java
com.iaraby.db.helper.DatabaseHelper.java
com.iaraby.db.helper.Util.java
com.iaraby.db.helper.lib.SimpleCursorLoader.java
com.iaraby.views.AddDialog.java
com.iaraby.views.KeepFragment.java
com.iaraby.views.MainActivity.java