KDP(電子出版)のメモ 急急如律令

Amazon Kindleダイレクト・パブリッシングでの電子出版や電子書籍の作成販売について、文章やイラストの作成や編集方法について書いています。

アンドロイドでiniを使う。

 

 アンドロイドで、PC用のiniを読み込んで使えないかなと気になったのでやってみた。アンドロイドでの設定の保存のやり方はSharedPreferencesやDataStoreを行うようだ。

PC用のiniはPropertiesで読み込めた。propをSharedPreferencesに変換して保存した。

 

        prop = new Properties();
        InputStream isini;
        try {
            isini = this.getAssets().open("AozoraEpub3.ini");;
            prop.load(isini);
        } catch (IOException e) {
            e.printStackTrace();
        }

        SharedPreferences dataStore = getSharedPreferences("DataStore", MODE_PRIVATE);
        SharedPreferences.Editor editor = dataStore.edit();

        Enumeration keys = prop.keys();
        while (keys.hasMoreElements()) {
            String key = (String)keys.nextElement();
            String value = (String)prop.get(key);
            System.out.println(key + ": " + value);
            // Key: input, value: text
            editor.putString(key, value);
        }
        //editor.commit();
        editor.apply();

 

Device File Explorer でDataStore.xmlに保存されている内容を確認すると。

 

developer.android.com

blog.kakakikikeke.com

alvinalexander.com

akira-watson.com

buildersbox.corp-sansan.com

stackoverflow.com