Android Open Source - blogwriter Version Transfer






From Project

Back to project page blogwriter.

License

The source code is released under:

GNU General Public License

If you think the Android project blogwriter 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

package com.example.blogerwriter;
/*  www. j  a  va 2s.co m*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.os.Environment;

public class VersionTransfer {
  
  private Context mContext;
  
  public VersionTransfer(Context context){
    mContext=context;
  }
  public void versionTransfer(){
    String sdpath=Environment.getExternalStorageDirectory().getAbsolutePath();
    String fileName="blog_isaid";
    ArrayList<HashMap<String, String>> datas=readText(sdpath,fileName);
    transferToDB(datas);
  }
  public void transferToDB(ArrayList<HashMap<String, String>> datas){
    
    DBHelper dbHelper=new DBHelper(mContext);
    dbHelper.open();
    for(HashMap<String, String> m:datas){
      dbHelper.insertData(m.get(DBHelper.KEY_DATA), m.get(DBHelper.KEY_DATE));
    }
  }
  public ArrayList<HashMap<String, String>> readText(String path,String filename){
    ArrayList<HashMap<String, String>> datas=new ArrayList<HashMap<String,String>>();
    File isaidFile=new File(path, filename);
    try {
      String str="";
      BufferedReader bReader=new BufferedReader(new FileReader(isaidFile));
      while((str=bReader.readLine())!=null){
        HashMap<String, String> mp=new HashMap<String, String>();
        mp.put(DBHelper.KEY_DATA, str);
        str=bReader.readLine();
        mp.put(DBHelper.KEY_DATE, str);
        datas.add(mp);
      }
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return datas;
  }

}




Java Source Code List

com.example.blogerwriter.DBHelper.java
com.example.blogerwriter.DataExporter.java
com.example.blogerwriter.ItemEditActivity.java
com.example.blogerwriter.MainActivity.java
com.example.blogerwriter.MemoActivity.java
com.example.blogerwriter.VersionTransfer.java