public static StringPool readStringPool(ByteBuffer buffer,StringPoolHeader stringPoolHeader){
  long beginPos=buffer.position();
  long[] offsets=new long[(int)stringPoolHeader.getStringCount()];
  if (stringPoolHeader.getStringCount() > 0) {
    for (int idx=0; idx < stringPoolHeader.getStringCount(); idx++) {
      offsets[idx]=Buffers.readUInt(buffer);
    }
  }
  boolean utf8=(stringPoolHeader.getFlags() & StringPoolHeader.UTF8_FLAG) != 0;
  long stringPos=beginPos + stringPoolHeader.getStringsStart() - stringPoolHeader.getHeaderSize();
  buffer.position((int)stringPos);
  StringPoolEntry[] entries=new StringPoolEntry[offsets.length];
  for (int i=0; i < offsets.length; i++) {
    entries[i]=new StringPoolEntry(i,stringPos + offsets[i]);
  }
  String lastStr=null;
  long lastOffset=-1;
  StringPool stringPool=new StringPool((int)stringPoolHeader.getStringCount());
  for (  StringPoolEntry entry : entries) {
    if (entry.offset == lastOffset) {
      stringPool.set(entry.index,lastStr);
      continue;
    }
    buffer.position((int)entry.offset);
    lastOffset=entry.offset;
    String str=ParseUtils.readString(buffer,utf8);
    lastStr=str;
    stringPool.set(entry.index,str);
  }
  buffer.position((int)(beginPos + stringPoolHeader.getBodySize()));
  return stringPool;
}

public static StringPool readStringPool ( ByteBuffer buffer , StringPoolHeader stringPoolHeader ) { long beginPos = buffer . position ( ) ; long [ ] offsets = new long [ ( int ) stringPoolHeader . getStringCount ( ) ] ; if ( stringPoolHeader . getStringCount ( ) > 0 ) { for ( int idx = 0 ; idx < stringPoolHeader . getStringCount ( ) ; idx ++ ) { offsets [ idx ] = Buffers . readUInt ( buffer ) ; } } boolean utf8 = ( stringPoolHeader . getFlags ( ) & StringPoolHeader . UTF8_FLAG ) != 0 ; long stringPos = beginPos + stringPoolHeader . getStringsStart ( ) - stringPoolHeader . getHeaderSize ( ) ; buffer . position ( ( int ) stringPos ) ; StringPoolEntry [ ] entries = new StringPoolEntry [ offsets . length ] ; for ( int i = 0 ; i < offsets . length ; i ++ ) { entries [ i ] = new StringPoolEntry ( i , stringPos + offsets [ i ] ) ; } String lastStr = null ; long lastOffset = - 1 ; StringPool stringPool = new StringPool ( ( int ) stringPoolHeader . getStringCount ( ) ) ; for ( StringPoolEntry entry : entries ) { if ( entry . offset == lastOffset ) { stringPool . set ( entry . index , lastStr ) ; continue ; } buffer . position ( ( int ) entry . offset ) ; lastOffset = entry . offset ; String str = ParseUtils . readString ( buffer , utf8 ) ; lastStr = str ; stringPool . set ( entry . index , str ) ; } buffer . position ( ( int ) ( beginPos + stringPoolHeader . getBodySize ( ) ) ) ; return stringPool ; }
read string pool , for apk binary xml file and resource table .
