なんか直接はできないみたい。

なので、使用前に saveSetting, 使用後に loadSetting で取り合えず使える。

※ ディフォルトのファイル名は、”パッケージ名+_preferences.xml”

void public saveSetting( Context c, String exterernalPath) {   
    String to = c.getFilesDir().getParentFile().getAbsoluteFile() + "/shared_prefs/my_setting.xml";
    // 外部SD->内部SD
    copyFile( exterernalPath, to ) ;
}

void public loadSetting( Context c, String exterernalPath) {   
    String to = c.getFilesDir().getParentFile().getAbsoluteFile() + "/shared_prefs/my_setting.xml";
    // 内部SD->外部SD
    copyFile( to, exterernalPath ) ;
}

public static void copyFile(String srcFilePath, String dstFilePath) {
    File srcFile = new File(srcFilePath);
    File dstFile = new File(dstFilePath);

    // ディレクトリを作る.
    File dstPath = new File(dstFile.getParent());
    dstPath.mkdirs();

    try {
        // ファイルコピーのフェーズ
        InputStream input = null;
        OutputStream output = null;
        input = new FileInputStream(srcFile);
        output = new FileOutputStream(dstFile);
        int DEFAULT_BUFFER_SIZE = 1024 * 4;
        byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
        int n = 0;
        while (-1 != (n = input.read(buffer))) {
            output.write(buffer, 0, n);
        }
        input.close();
        output.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

内部SDにDBを保存するとツール等使って直接参照できません。
てっ事で、外部SDに保存する方法が以下です。
あっ、OSのバージョンよっては出来ないのもあるのかな?
4.X 系はOK

public class DatabaseHelper extends SQLiteOpenHelper {
    private final static int DB_VERSION  = 1;
    public final static String DB_NAME = "mydb.db";

    public DatabaseHelper(Context context) {
        super(context, 

            Environment.getExternalStorageDirectory().getAbsolutePath() + "/hogehoge/" + DB_NAME, 
            null, 
            DB_VERSION);
    }

}

FireFox のプラグインとなります。

Fillder ほど細かくなくてよくて、ちょっと簡単にって感じの時におすすめ

FireFox のプラグインです。
このプラグインを使用することで、PCのブラウザーからあたかもAndroid、iphone からアクセスした様に見せる
事ができます。

android
Mozilla/5.0 (Linux; U; Android 4.0.1; ja-jp; Galaxy Nexus Build/ITL41D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

iphone
Mozilla/5.0 (iPod; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3

久しぶりに便利ツールみつけました。
FireFox plugin Postger

GET はURLにパラメータを追加するので簡単に呼べますが、Post はボディーに設定する
必要があるので簡単に値を変更して呼び出す事ができません。

そこで上記の Poster を利用します。
header Agent 色々変更できるので、サーバ側のAPIの確認など捗ります。

POSTでパラメータを配列で渡すことになりました。
(@_@)

連想配列ならピンとくるんですが、ただの配列ってなあに?
調べた結果

GETイメージだと
http:/localhost/request.php?hoge[]=a&hoge[]=b&hoge[]=c
てな感じです。

でっ Android で指定するには?

HttpPost httpPost = new HttpPost(url);

List<NameValuePair> para = new ArrayList<NameValuePair>() ;
for( String hoge : list ) {
	para.add( new BasicNameValuePair("hoge[]", hoge));
}
httpPost.setEntity(new UrlEncodedFormEntity( para, "UTF-8"));
HttpResponse response = httpclient.execute(httpPost);

以下設定

android-15 以上ならSDKにソースが付属されています。

eclipse
設定->Javaのビルドパス->ライブラリー->Android 4.0.3->android.jar->ソース添付
編集ボタン->外部フォルダー
ex.C:/android-sdk_r20.0.3-windows/android-sdk-windows/sources/android-15
[/text:
上記でソースデバック出来ます。

long time = dateA.getTime() dateB.getTime();
// 一分未満の端数を求めて、分に変換
long sec = ((time  % ( 1000 * 60 * 60 * 60)) / 1000)  % 60;
// 一時間未満の端数を求めて、分に変換
long min = ((time  % ( 1000 * 60 * 60)) / 1000 / 60) % 60;
// 何時間かを求める
long hour = ( time / ( 1000 * 60 * 60));
String strTime = hour + "h" + min + "m" /* +sec + "s" */;
© 2024 Falco Tech Blog Suffusion theme by Sayontan Sinha