I am trying to check the integrity of a database file in asset folder and i am using this code in android app.
I don’t know in it is correct to directly convert InputStream to string
My question is that in this code how to convert the file in assets folder in string.
I tried BufferdReader as
AssetManager am = getResources().getAssets();
String as = null;
InputStream is=null;
StringBuilder sb = new StringBuilder();
try {
is=am.open("sdapk.db");
BufferedReader br= new BufferedReader(new InputStreamReader(is));
while ((as=br.readLine())!=null) {
sb.append(as + "\n");
}
is.close();
}catch(IOException e) {
Log.v("Error_E",""+e);
}
String res = md5(sb.toString());
but no luck
please shed some light on this and guide me in right direction.
Thanks!
\n might change the original content resulting in different MD5. Some system use \r for carriage return.
You should use the inputstream directly as following